tamiifrog
tamiifrog

Reputation: 15

WebForms - Response.Redirect() does not change URL

I do have a big problem and can't find any solution.

I have three .aspx pages. 1) Login 2) Menu 3) Days

Login page has a Button:

<asp:Button ID="bt_login" onClick="bt_login_Click" runat="server" Text="Login" />

and this method:

protected void bt_login_Click(object sender, EventArgs e)
{
     Response.Redirect("~/Menu.aspx");        
}

When I click the Button it redirects to Menu.aspx but the URL still says Login.aspx So when I click any Button in Menu.aspx it will direct me back to Login.aspx

When I tried to put the Redirect into the Page_Load method it worked, why?

Can anybody help me please?

Upvotes: 1

Views: 2618

Answers (2)

chuck
chuck

Reputation: 57

I have the same issue when I use jquery mobile.

        If FormsAuthentication.Authenticate(strUsername, strPassword) Then
            FormsAuthentication.RedirectFromLoginPage(strUsername, False)
        Else
            ' show login error
            lblLoginError.Visible = True
        End If

It takes me to the default.aspx page after I authenticate, but the url of the page has a return url listed and the css not working correctly.

I commented this out (below) and it works:

      <script src="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.js"></script>

Upvotes: 0

naspinski
naspinski

Reputation: 34689

Your are likely using authentication of some sorts (Windows/Forms/etc) and and you are not logged in. Check your web.config, as it probably has a redirect to the login page until you are logged in. The menu.aspx page is not allowed unless you are logged in, am I correct?

Upvotes: 1

Related Questions