In some situation we would like to auto login user into the
application:
-
Single sign-on: When we have multiple modules in
application with different credentials and login scheme & single sign-on (like
open id) is not implemented. In such cases we need to implement custom login,
so that user feel like single sign-on while moving to different modules of the
application.
-
If the current user (on client) is part of a
specific Group.
-
During debugging we'd like the app to log in
automatically with a test account, so we can check the functionality of the
role assignments, and not have to go through entering credentials on the login
page each time.
Solution:
On Login page’s page load event user below code:
if (!string.IsNullOrEmpty(Request.QueryString["ReturnUrl"]))
{
if (/*Write logic to verify the condition for auto login*/)
{
FormsAuthentication.RedirectFromLoginPage("xxxUser", false);
return true;
}
}
/*Rest of the code, to validate user*/
|