FormsAuthentication.RedirectFromLoginPage

  • Thread starter Thread starter Mike P
  • Start date Start date
M

Mike P

When you have authenticated a user and you call
FormsAuthentication.RedirectFromLoginPage, 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?
 
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 RedirectFromLoginPage, 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
 
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>
<authentication 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top