Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

asp.net forms authentication redirect problem

Tags:

asp.net

The default document feature is turned off in IIS and here's the situation...

My start page for my project say is A.aspx. I run the project and sure enough, A.aspx appears in the url of the browser. Like it should though, A.aspx finds no user logged in and redirects to Login.aspx like it should.

A.aspx:

    if (Session["UserStuff"] == null)
        Response.Redirect("~/Account/Login.aspx"); 

The login.aspx shows up BUT when the user Logs in, the code:

FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, true);

always redirects to "Default.aspx" and not "A.aspx"

I've examined FormsAuthentication.GetRedirectUrl and sure enough it returns "Default.aspx"

I'm stumped????

like image 625
Bob Avatar asked Dec 12 '25 07:12

Bob


1 Answers

In web.config you could set the default page using the defaultUrl attribute:

<authentication mode="Forms">
    <forms 
       loginUrl="login.aspx" 
       defaultUrl="a.aspx"
       protection="All"  
       timeout="30" 
    />
</authentication>
like image 126
Darin Dimitrov Avatar answered Dec 15 '25 06:12

Darin Dimitrov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!