asp.net
To prevent the same user from landing at the same time, the home page should record the information of the online user (here with the user name for example), and then determine whether the user is logged in. Use a cache to store the username that has been logged in, but there is one more question to know when the user left the system. This is to periodically clear the contents of the cache, that is, set a cache time. This time can be associated with the user's session value, and the user's information in the cache is emptied as soon as the user's session value is invalidated. This is achieved to prevent the simultaneous landing effect, the specific code is as follows:
Place on the successful landing:
string key = TextBox1.Text; User name textbox set to cache keyword
String uer = Convert.ToString (Cache[key]); Read the user's corresponding value in the cache
To determine if there is a user's information in the cache, if there is no relevant value, indicating that the user did not log in
if (Uer = null | | uer = = String.Empty)
{
Define cache Expiration Time
TimeSpan sesstimeout = new TimeSpan (0, 0, System.Web.HttpContext.Current.Session.Timeout, 0, 0);
Insert a user-related cache value on the first landing
HttpContext.Current.Cache.Insert (key, key, NULL, DateTime.MaxValue, Sesstimeout, System.Web.Caching.CacheItemPriority.NotRemovable, NULL);
session["Adminid"] = TextBox1.Text;
Response.Redirect ("main". ASPx ");
}
Else
{
Repeat Login
Response.Write ("");
}