Tuesday, October 19, 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:



New Class Is The Blue Ocean



MPEG4 to WMV



EASY to use Converters And Optimizers



Baidu Lotte Joint Venture Formation Of Landed Four Domestic B2C



Lean SHIPBUILDING Theory and Practice in Foreign



7 completely remove the USB device hardware approach



Listed six prominent force in the award-winning character Aisino A6



the best QUALITY printer paper



VOB to WMV



Dynamic Power-BIV5.3.1 Chi Aowei smooth fat version!



Five Easy Way To Get Repeat Customers



3GP to WMV



The Hai Lute: National, World's



Development Shop



No comments:

Post a Comment