Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET redirecting to a page other than the default redirect url

In asp.net we specify the redirect url when using forms authentications like this:

<authentication mode="Forms">
            <forms name="myApp" loginUrl="Login.aspx" protection="All" defaultUrl="default.aspx" path="/" requireSSL="false"/>
        </authentication>

this means that when a user log in, will be redirected to "default.aspx" using this method

FormsAuthentication.RedirectFromLoginPage(IDTextBox.Text, RememberCheckBox.Checked);

Now is it possible to make the user choose which page to be redirected to prior to login ?

for example the user chooses from a list the page to login to prior to login then when authenticated be redirected to this page instead of the default.aspx page.

is that possible and if so how can this be done ?

like image 289
Mina Wissa Avatar asked Dec 29 '22 12:12

Mina Wissa


1 Answers

Instead of using the RedirectFromLoginPage method you could use the SetAuthCookie method and then redirect manually:

FormsAuthentication.SetAuthCookie(IDTextBox.Text, RememberCheckBox.Checked);
Response.Redirect("some url the user has choosen");
like image 74
Darin Dimitrov Avatar answered Jan 03 '23 17:01

Darin Dimitrov