FormsAuthentication.RedirectFromLoginPage

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike P

    FormsAuthentication.RedirectFromLoginPage

    When you have authenticated a user and you call
    FormsAuthentica tion.RedirectFr omLoginPage, how does it know what is the
    default page that it is supposed to redirect to? The page I want it to
    redirect to upon successful login is main.aspx, but it just says that
    default.aspx does not exist.

    How do I change it so that it tries to redirect to main.aspx instead of
    default.aspx?



    *** Sent via Developersdex http://www.developersdex.com ***
  • jj

    #2
    Re: FormsAuthentica tion.RedirectFr omLoginPage

    Hello Mike,

    When you enabled forms authentication, you specified the login page,
    right?. So, by default, if you try to access any other page in your
    application, you will be redirected to the login page. The name of the
    that you had requested originally will be persisted (querystring,
    maybe, I don't remember). When you call RedirectFromLog inPage, you
    should be redirected to the original page.

    Are you getting this problem while running from VS.Net, or directly
    through browser?
    If this is from VS.Net, have you set a start page that is NOT the
    login page?
    If this is from browser, have you set default page for your web site/
    virtual directory in IIS?

    Regards,
    Jim


    Regards,

    Jim

    Comment

    • Terry Rogers

      #3
      Re: FormsAuthentica tion.RedirectFr omLoginPage

      How do I change it so that it tries to redirect to main.aspx instead of
      default.aspx?
      You can set the default url to redirect to in the web.config file:
      <system.web>
      <authenticati on mode="Forms">
      <forms loginUrl="~/login.aspx" defaultUrl="~/main.aspx" />
      </authentication>
      </system.web>

      This will however be ignored if the return url is specified in the
      query string on the log in page (as it is when the user is redirected
      to the log in page when requesting other page).

      Terry

      Comment

      Working...