Specify page?

  • Thread starter Thread starter LL
  • Start date Start date
L

LL

Hi,

If the return key does not exist, RedirectFromLoginPage redirects to
Default.aspx. How to set it up, so if the return key dones not exist, will
retirect to mypage.aspx?

Thansk..
 
The only time there is not a redirect page is when the user types in the
logon page. And, yes, this one has bit me on the butt, as well.

You can test for the Redirect URL by two means:

1. FormsAuthentication.GetRedirectUrl
Will have to have auth cookie set prior to this
2. Request["ReturnURL"]
If no URL is set, you can redirect.

Something like:

if(FormsAuthentication.Authenticate(name,password))
{
if(Request["ReturnURL"] != null)
{
FormsAuthentication.RedirectFromLoginPage(name,false);
}
else
{
FormsAuthentication.GetAuthCookie(name, false);
Response.Redirect("redirectPage.aspx");
}

}
else
{
// TODO: What if user not authenticated
}

You will have to tweak this to your use. You will probably want to test for
redirect URL on first request and set a variable based on this value, as I
am not sure it will work in the button_click event, as shown. I have not
tested this code, so it is simply a road map to a potential methodology.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

**********************************************************************
Think Outside the Box!
**********************************************************************
 
Back
Top