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