开发者

Forms authentication practice

开发者 https://www.devze.com 2023-02-15 13:39 出处:网络
I am wondering why that programmer used a try block. Is that a famous practice try { FormsAuthentication.RedirectFromLoginPage(username, pass;

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消