<! -- Startfragment --> private void login_click (Object sender, system. eventargs E)
{
// The key as the unique identifier should be unique, which can be set as needed.
// For the test of Yu's cadmium, there is no rabbit, there is no vinegar, there is no gray, the call is very good? BR>
// Generate the key
String skey = username. Text + "_" + password. text;
// Obtain the value of the given key in the cache
String suser = convert. tostring (Cache [skey]);
// Check for existence
If (suser = NULL | suser = string. Empty)
{
// The project where the key is not found in the cache. The table name user is not logged on or has timed out.
// Note that the following method of using the timespan constructor to overload the version is the key to determining whether to log on.
Timespan sesstimeout = new timespan (0, 0, system. Web. httpcontext. Current. session. Timeout, 0 );
Httpcontext. Current. cache. insert (skey, skey, null, datetime. maxvalue, sesstimeout,
System. Web. caching. cacheitempriority. notremovable, null );
Session ["user"] = skey;
// Log on for the first time. You can do what you want.
MSG. Text = "<H4 style = 'color: red'> Hi! Welcome to <a href = 'HTTP: // DOTNET. aspx. CC/'> [wonderful world of the mengxian summit ]";
MSG. Text + = "</a>. Have a good time! :) </H4> ";
}
Else
{
// This user's record is found in the cache. The table name has been logged on and cannot be logged on again.
MSG. Text = "<H4 style = 'color: red'> sorry, you seem to have logged on:-(</H4> ";
Return;
}
}
Is the minute or the total minute of the difference ??
For example
2006-1-1 12:30:30
2006-1-1 11:31:30
The minute part is 1
The total number of minutes is 61.
Use timespan. Minutes or timespan. totalminutes