I'm implementing some asp.net application in .NET Framework 1.1. Within that application I want to implement some security policy like as follows
- When user login to the system, and copies the url and paste it into other browser, then that new browser should redirect to him on login page.
- When开发者_高级运维 user is browsing application, copy the current url, logout, paste the url to a new browser then he should be redirected to the login page.
Please help me implement this type of security in asp.net 1.1
You can set session variable on login page. Create one function "IsLoggedIn" and in this function check whether value is set for session or not. If not than user is not logged in and show login page. This function you need to copy on each page's page_load event. Make sure you reset session or make it null once user logs out.
public static bool IsLoggedIn()
{
if (System.Web.HttpContext.Current.Session["UserName"] != null && Convert.ToString(System.Web.HttpContext.Current.Session["UserName"]) != String.Empty)
{
return true;
}
else
{
return false;
}
}
if (!IsLoggedIn())
{
Server.HtmlEncode(Request.Url.ToString());
Response.Redirect("Login.aspx" + "?ReturnUrl=" + (Request.FilePath));
}
精彩评论