Forms authentication practice
I am wondering why that programmer used a try block. Is that a famous practice
try
{
FormsAuthentication.RedirectFromLoginPage(username, pass;
}
catch
{
string strURL = (null != Request.QueryString["ReturnURL"] && Request.QueryString["ReturnURL"] != "") ? Request.QueryString["ReturnURL"] : "Default.aspx";
FormsAuthentication.SetAuthCookie(user开发者_如何学Cname, pass);
Response.Redirect(strURL);
}
Thanks
Method can throw. Here's a part of it:
// ....
if (CookiesSupported || IsPathWithinAppRoot(current, returnUrl))
{
// ....
}
else
{
if (!EnableCrossAppRedirects)
{
throw new HttpException(SR.GetString("Can_not_issue_cookie_or_redirect"));
}
// ....
}
// ....
You can see all of it in the Reflector yourself.
ReturnURL is a parameter that specify where to go after login. If it is missing you may want handle it to Default.aspx, thats all.
精彩评论