Specify page?

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..
 
C

Cowboy \(Gregory A. Beamer\)

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!
**********************************************************************
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top