Friday, October 8, 2010

ASP.NET 2.0 at the same time to prevent the same user login



To prevent the same user while landing page should record the information online (in this case the user name), and then determine which are the user login is already exists. Here has been to use a cache store login user name, but there is a problem is to know when the user is away system? This should clear the cache content on a regular basis, and that is to set a cache time. This time can be the user's session with the value of link failure happens when the user session when the value of the user information in the cache will be empty inside. This reached the landing of the effect of preventing the same time, the specific code as follows:

On the landing place of success:

string key = TextBox1.Text; / / user name text box set to cache Keyword

string uer = Convert.ToString (Cache [key]); / / read the corresponding value of the user cache

/ / Determine whether the cache in the user's information, if the value is not relevant, the user does not login

if (uer == null | | uer == String.Empty)

(

/ / Define cache expire time

TimeSpan SessTimeout = new TimeSpan (0, 0, System.Web.HttpContext.Current.Session.Timeout, 0, 0);

/ / Insert the first time a user login related to cache values

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







Recommended links:



DivX to Zune



Skyworth the SECRET of surviving



"Grey Dove" into a small penguin confuse users into a "chicken"



Hot Firewall And Proxy Servers



Media, how to deal with the phenomenon of public relations in society



solutions ibm as400 SERIES



Joint Commerce and Industry of India: India Will rely heavily on computer hardware in China



Whirlpool eventually favored by the United States and Thailand was designated as the optimum board b



Good News Servers



DAT to 3GP



How to revive the old floppy drive?



With a good wind Power, send me Albatron



MTS To AVI



ICP license issue processing



No comments:

Post a Comment