Click here to Skip to main content
13,862,971 members
Rate this:
Please Sign up or sign in to vote.
Hi all,

I'm facing a really weird scenario here with my local IIS. I have hosted multiple sites in the default website in my local IIS. One of them has the login page. From the login page, I'm redirecting the user to another page that is located in another site (which is also hosted in the same IIS inside default website virtual directory).

Now in the submit button click event of my login page, after authenticating the user, I have written a "Response.Redirect(redirect_url)". the redirect_url is being formed dynamically and given as a parameter to the Redirect method.

While debugging, the final redirect_url that is being sent as parameter to Redirect method is:


But after I try to go to the next step, I'm suddenly getting a HTTP 404 error saying that the resource doesn't exist and I have observed that Requested URL shown in the error page is different that what was dynamically sent to the Response.Redirect(...) method.

In the error page, the requested url shows the value as


whereas my actual requested url formed in the code is:


I'm just unable to understand why the requested url is getting changed automatically.! Also, I observe that "localhost" is being appended to the requested URL again which is not what is supposed to happen.

Please visit THIS link[^] to understand this question more clearly. I have added screen shot of the error page and also my code snippets.[^]

Thanks a lot.!
Updated 20-Sep-17 5:58am
hitesh_tech 16-Sep-13 9:11am
what is CPLogin is this aspx page or folder inside localhost ?
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

It seems that you have any of following scenarios running with you

1- Request was arrived on the right page "Console.aspx". But inside errorHandling you received code 5 and then you redirected it to page CPLogin with querystring parameter err=5. [and while redirection your redirect URL goes invalid]

2- If not point 1, Go to your web.config file and check for your Authentication -> Forms -> LoginURL property. "It might be a case that you are redirecting a user to the link [you are facing 404] as a default page"

3- if not point 2, Go to your web.config file and check for your CustomErrors -> DefaultRedirect. as you might be getting some error on your page Console.aspx and then it automatically gets redirected to CPLogin.aspx [again here your redirection URL is not correct which cause 404 and wrong invalid URL displayed in address bar]
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Indeed, the problem was with the way I had hosted the sites in my application. I just removed all the sites related to my application from IIS and then hosted all of them again much more carefully. This resolved the "wrong redirect url" problem.

Also, I had some tables with missing required data because of which I was getting the error code.

So after I got all the tables filled with the required data and also after properly hosting the application in IIS, my problem got resolved.
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

I had the same problem, but resolved it in the binding. In my case I had two ip addresses but only one was bound when the website was created. It was resolved by adding a second binding that featured the 2nd ip address.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Cookies | Terms of Service
Web04 | 2.8.190214.1 | Last Updated 20 Sep 2017
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100