FormsAuthentication.RedirectFromLoginPage Method (String, Boolean, String)
Assembly: System.Web (in system.web.dll)
public: static void RedirectFromLoginPage ( String^ userName, bool createPersistentCookie, String^ strCookiePath )
public static void RedirectFromLoginPage ( String userName, boolean createPersistentCookie, String strCookiePath )
public static function RedirectFromLoginPage ( userName : String, createPersistentCookie : boolean, strCookiePath : String )
Not applicable.
Parameters
- userName
The authenticated user name.
- createPersistentCookie
true to create a durable cookie (one that is saved across browser sessions); otherwise, false.
- strCookiePath
The cookie path for the forms-authentication ticket.
The RedirectFromLoginPage method redirects to the return URL specified in the query string using the ReturnURL variable name. For example, in the URL http://www.contoso.com/login.aspx?ReturnUrl=caller.aspx, the RedirectFromLoginPage method redirects tothe return URL caller.aspx. If the ReturnURL variable does not exist, the RedirectFromLoginPage method redirects to the URL in the DefaultUrl property.
ASP.NET automatically adds the return URL when the browser is redirected to the login page.
By default, the ReturnUrl variable must refer to a page within the current application. If ReturnUrl refers to a page in a different application or on a different server, the RedirectFromLoginPage method redirects to the URL in the DefaultUrl property. If you want to allow redirects to a page outside the current application, you must set the EnableCrossAppRedirects property to true using the enableCrossAppRedirects attribute of the forms configuration element.
Security Note: |
|---|
|
Setting the EnableCrossAppRedirects property to true to allow cross-application redirects is a potential security threat. When cross-application redirects are allowed, your site is vulnerable to malicious Web sites that use your login page to convince your Web site users that they are using a secure page on your site. To improve security when using cross-application redirects, you should override the RedirectFromLoginPage method to allow redirects only to approved Web sites. |
If the CookiesSupported property is true, and either the ReturnUrl variable is within the current application or the EnableCrossAppRedirects property is true, then the RedirectFromLoginPage method issues an authentication ticket and places it in the cookie specified by the strCookiePath parameter using the SetAuthCookie method.
If CookiesSupported is false and the redirect path is to a URL in the current application, the ticket is issued as part of the redirect URL. If CookiesSupported is false, EnableCrossAppRedirects is true, and the redirect URL does not refer to a page within the current application, the RedirectFromLoginPage method issues an authentication ticket and places it in the QueryString property.
Security Note: