0
votes

I am making a Login page in Visual Studio with C#, so after inserting user and password I click on the button login, what I want is to redirecte on the "Default.aspx" page after I click on the button. I tried this ways to do it:

Response.Redirect("Default.aspx"); //This is inside the method that makes the Login controls

ButtonName.Attributes["onclick"] = "javascript:window.open('LoginControlMethod.aspx'); return false;"; //Different way I tried in the same point of the method

Thoese two just change my URL from http://localhost:56528/Account/Login.aspx to http://localhost:56528/Account/Login.aspx?ReturnUrl=%2fAccount%2fDefault.aspx

So the point is, I can make it work only by URL like, but I don't like it much.

Response.Redirect("http://localhost:56528/Default.aspx")

P.S. I have low experience with C#, still learing, like I am really new. Really new.

1
The URL to which you are redirected suggests that you're not logged in. You must let the login run it's course and only after that's complete issue the redirect. Sharing more of your code might help highlight what's going on. Could you share all of your markup and code for the login page please? - Ian Newson

1 Answers

0
votes

Change Response.Redirect("Default.aspx"); to Response.Redirect("~/Default.aspx");.

I suspect your login control is within the Account directory, which means the redirect is relative to that directory. Adding ~/ makes it relative to the root of the application.