This method is used to Redirects the browser to the login
URL. But sometime this function not works as expected and user is not sent to
login page.
As defined in MSDN documentation
“Unlike the HttpResponse.Redirect method, this method
does not end the request by calling HttpResponse.End. This means that code that
follows the RedirectToLoginPage method call will run.”
If FormsAuthentication.RedirectToLoginPage() method not working as
expected that means code in the Page life cycle after your call to
RedirectToLoginPage is running, and throwing a NullReferenceException.
Solution: Write Response.End() after FormsAuthentication.RedirectToLoginPage(), and it will work fine then.
Note: If you want to know details about what the actual
response contains when the method is called and why there is Null reference
exception, you can use a trace tool such as Fiddler to see.
Comments
Post a Comment