Question

I am trying to test simple changes to a web page, locally. I am using VS 2008 and VB.net. I enter the page that I would like to go to. But it needs a login, so it correctly takes me to the login page. I can successfully login using a test account. Then it redirects to the 'ReturnUrl' but the page that is displayed is the login page, not the one listed in the address bar which is the correct value - 'ReturnUrl' variable.

I tried using Fiddler2 to see if there are any problems, but there are not. It shows the redirection to the proper page and the URL is the page I want to see but what is displayed in the browser (FireFox) is the Login page.

Here is the code that redirects the page:

If Request.QueryString("ReturnUrl") = "" Then
    Response.Redirect("profile.aspx")
Else
    Response.Redirect(Request.QueryString("ReturnUrl"))
End If

I checked the ReturnUrl value and it is the correct url. No errors are displayed but the Login page is shown with the text boxes of the Login page (profile.aspx) cleared. The URL shown in the window is the 'ReturnUrl'.

Does anybody have an idea of what is going wrong?

Was it helpful?

Solution 2

For any poor souls who are struggling with this issue, this is what worked for me...

I am running this locally. That is the key! In my code, there were 2 cookies created before the .Redirect method call: The code looked like this:

 Dim C As HttpCookie
 C = FormsAuthentication.GetAuthCookie(custID.ToString, False)
 C.Domain = "ourdomain.com"
 Response.AppendCookie(C)

 Dim C2 As System.Web.HttpCookie = New System.Web.HttpCookie("ProfileUsername", P.UserName)
 C2.Domain = "ourdomain.com"
 Response.AppendCookie(C2)

I needed to change the .Domain to ".localhost". It MUST have at least one dot in the name.

Also, in the web.config file, in the element authentication. The 'mode' is 'Forms'. An attribute of 'Forms' is domain=".localhost"

That got my test to accept my test member and move on to the part of the code that I needed to test.

OTHER TIPS

tried a lot of suggestions. only this worked. place code at your default.aspx page.

 Private Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load

    Dim strRedirect As String

    strRedirect = Request.QueryString("ReturnUrl")

    If (strRedirect <> "") Then

        Response.Redirect("~/Default.aspx", True)

    End If

End Sub
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top