asp.net - How to determine Session Timeout using when reusing CookieContainer -


I have the following code that uses a cookieContainer that enters the previous request again, but for now the cookie Uses container After the request

After a period of time if the waste will end a session on the site, I will need to login again

Question:. I can determine (a container with cookies object) if the time has expired or whether the best way to determine this is to http Vebbeshns which contains text such as 'Session Timeout' is the best way to do what is?

  Private Static Cookie Container _cookieContainer; Private static CookieContainer CurrentCookieContainer {(get {if (_cookieContainer == null || _cookieContainer.Count == 0) {lock (_lock) {if (_cookieContainer == null || _cookieContainer.Count == 0) {// _ cookieContainer. GetCookies _cookieContainer = DoLogin ();}}} _cookieContainer return;} set {_cookieContainer = value;}}  

and then call out the method container:

  Public Static String SomeMethod (some P) {HttpWebRequest request_thirdPartyEnquiryDetails = (HttpWebRequest) WebRequest.Create; Cookie Container Cookie Container = CurrentCookieContainer; request_thirdPartyEnquiryDetails.CookieCon Tainer = cookiecontaine R; // ... and it goes on submitting a search and returning the response}  

Well, expiration after 30 minutes, I have to re-login after 25 minutes.

  private static Date time? lastLoggedIn; private static cookie Kantaneyr _cookieContainer; Private static CookieContainer CurrentCookieContainer {if (_cookieContainer == null || _cookieContainer.Count == 0 || lastLoggedIn.HasValue || lastLoggedIn.Value.AddMinutes (25) to & lt; DateTime.Now) received {{lock (_lock) { if (! _cookieContainer == null || _cookieContainer.Count == 0 || lastLoggedIn.HasValue || lastLoggedIn.Value.AddMinutes (25) of & lt; DateTime.Now) {_cookieContainer = DoLogin (); Previous log-in = date time.Now; }}} Return _cookieContainer; } Set {_cookieContainer = value; }}  

As an additional precaution, I check HTTP response for the text which returns the end of the page session (although it is no longer expected) . If this happens, then I set the blank to the last long date and then set the search method to run.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -