2
votes

I'm using forms authentication to authenticate a user and then redirect the user to welcome page, which is Welcome.aspx. When the user credentials are valid, then the user will be redirected to Welcome.aspx page.

I am using FormsAuthentication.RedirectFromLoginPage() method to redirect the user to the welcome page, but for some reason the FormsAuthentication.RedirectFromLoginPage() method is redirecting the user to Default.aspx.

Web.Config Code:

 <system.web>
    <compilation debug="true" targetFramework="4.0" />
    <authorization>
      <deny users="?"/>
    </authorization>
    <authentication mode="Forms">
      <forms loginUrl="~/Login.aspx" timeout="2880"  defaultUrl="~/Welcome.aspx"/>
    </authentication>
3

3 Answers

0
votes

That's going to redirect the user to the page they were just viewing. That's why it goes back to default.aspx. You just need to issue a redirect to the actual welcome page--statically.

0
votes

The DefaultUrl property is used by the RedirectFromLoginPage method if no return URL is included in the request.

so you may have Default.aspx as return URL, or you may have set Default.aspx as defaultDocument

0
votes

You are only allowing authorized user to acccess the pages by specifying <deny users="?" />

Add this to your web.config file for welcome.aspx redirect.

<location path="Welcome.aspx">
    <system.web>
        <authorization>
            <allow users="*" />
        </authorization>
    </system.web>
</location>