Re: Quick ? on Forms Authentication

From: Scott Mitchell [MVP] (mitchell_at_4guysfromrolla.com)
Date: 10/27/04


Date: Wed, 27 Oct 2004 15:27:52 GMT

oakleyx wrote:
> I'm using asp.net form authentication. The problem i'm having is when
> my cookie expires it redirects me to the login page, so I log in again
> and it brings me to the page that I was on last before the cookie
> expired.
>
> Is there something I can do so that after I login it always redirect
> to the Default.aspx page?

Daniel, the reason it's redirecting you to the page you were on is
because you are calling FormsAuthentication.RedirectFromLoginPage() to
log the user on from your Logon.aspx page, no? This, as its name
implies, redirects the user back to the page they came from.

Using Reflector - http://www.aisto.com/roeder/dotnet/ - you can see that
this method simply calls FormsAuthentication.SetAuthCookie(), and then
manually does a Response.Redirect(). So, if you want to send users to
Default.aspx from your Logon page, when they login, instead of using
RedirectFromLongPage(), use SetAuthCookie() and then
Response.Redirect("Default.aspx")

Here's a link to the technical docs for FormsAuthentication.SetAuthCookie():
http://tinyurl.com/66syy

Happy Programming!

-- 
     Scott Mitchell
     mitchell@4guysfromrolla.com
     http://www.4GuysFromRolla.com
		
* When you think ASP.NET, think 4GuysFromRolla.com!


Relevant Pages

  • Re: Forms Authentication - Confused!
    ... Again, the authentication occurs correctly, but the secured resource does ... not think the user is authenticated, following the login. ... > If you would like to zip your solution and email it to me (take out secure ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: RedirectFromLoginPage
    ... Much appreciated Greg. ... > redirects you to page of choice after logging in. ... > If you do login succesfully, then attempt to go to page your are not ... > Private Sub Page_Load(ByVal sender As System.Object, ...
    (microsoft.public.dotnet.languages.vb)
  • Quick ? on Forms Authentication
    ... I'm using asp.net form authentication. ... my cookie expires it redirects me to the login page, ... Is there something I can do so that after I login it always redirect ...
    (microsoft.public.dotnet.framework.aspnet)
  • Quick ? on Forms Authentication
    ... I'm using asp.net form authentication. ... my cookie expires it redirects me to the login page, ... Is there something I can do so that after I login it always redirect ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: RedirectFromLoginPage
    ... redirects you to page of choice after logging in. ... If you do login succesfully, then attempt to go to page your are not ... Private Sub LoginClick() ... requested (returnURL = nothing when clicked on logout) ...
    (microsoft.public.dotnet.languages.vb)