Wednesday, October 20, 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:



What conditions should be Maliciously registered domain name?



MATHEMATICS Education brief



JSP Experience Of Learning About The Steps And Timing



DivX TO 3GP



Teach you when the head: how to reduce your staff turnover rate?



FLV to SWF



SAP Henning dialogue: a complete Understanding of China



Who is "Green Dam" in pay?



Wang Yukun: Power In The Union Heavy Industry "butterfly"



My Favorite Themes And Wallpaper



Jusched.exe What process? How to disable?



ASF to MPG



Wealth Life - Interview With Dr. Xin Rong Record



Best Religion



The implementation of EU environmental directives will rob the U.S. Green Certification in China



Astrology OR Biorhythms Or Mystic Expert



Computer Clean Up Software Review How To Scan



No comments:

Post a Comment