Increased in the web.config & lt; The sessionState mode="InProc" timeout="1800" & gt; & lt;/sessionState> Not
Secondly I also found that this kind of situation. If use the HttpRuntime Cache or static also found this problem,
using System;
Using System. Collections. Generic;
Using System. IO;
Using System. Linq;
Using System. The Web;
Using System. Web. SessionState;
Using System. Xml;
The namespace ECInterSys
{
///& lt; summary>
///testSession summary description
///& lt;/summary>
Public class testSession: IHttpHandler, IRequiresSessionState
{
Public void the ProcessRequest (HttpContext context)
{
The context. The Response. ContentType="text/plain";
String login=context. The Request (" login ");
If (login!=null& & The login. The Equals (" yes "))
{
String loginName=context. Request [" loginName "];
//string PWD=context. The Request (" PWD ");
//... Validating a user's password
String newToken=Guid. NewGuid (). The ToString ();
The context. The Session [newToken]=loginName;
//writeFile (newToken, loginName);//the demo of external file is written to the server, if carry out this sentence, then again when access to the context. The Session (token)==null
The context. The Response. The Write (newToken);
return;
}
String token=context. The Request (" token ");
if (! String. IsNullOrEmpty (token))
{
//verification token
If (context. The Session!=null& & The context. The Session [token]!=null)
{
Context. The Response. The Write (context. The Session/token);
return;
}
}
The context. The Response. Write (" hello!" );
}
//test Session storage if write to local file Session message
//example written to a local file content is for reference only, do not write in practical use login information
//sample just said need to write an external file
Private void writeFile (string token, string loginName)
{
The string fileName=the string. Format (@ "{0} bin \ outerFile", AppDomain. CurrentDomain. BaseDirectory. ToString ());
Try
{
XmlDocument XML=new XmlDocument ();
if (! File. The Exists (fileName))
{
XmlDeclaration declaration=XML. CreateXmlDeclaration (" 1.0 ", "GB2312", "");//statement part of the XML document
XML. The AppendChild (declaration);
XmlElement xeRoot=XML. The CreateElement method (" root ");//create a & lt; Thumb> Node
XML. The AppendChild (xeRoot);
}
The else
XML. The Load (fileName);
XmlNode xnRoot=XML. SelectSingleNode ("//root ");
XmlElement xeSub=XML. The CreateElement method (" item ");
XeSub. SetAttribute (" ID ", token);
XeSub. SetAttribute (loginName, loginName);
XML. The Save (fileName);
}
The catch (Exception ex)
{
throw ex;
}
}
Public bool IsReusable
{
The get
{
return false;
}
}
}
}
CodePudding user response:
Firstly, we keep the session to the service rather than a process.Mode="StateSetver" and open asp.net _state service.
The second.. Even if you use InProc also won't appear the session immediately lost.
So you are the time request is a session?
CodePudding user response:
According to the big though moral emperor supreme instructions, we cannot make any speculative Suggestions to you ask, because it certainly doubt you for weak-minded, belong to bully, teach new typical replySo we can't tell you, whether should first check whether the file directory have write access,
We also can't tell you
The string fileName=the string. Format (@ "{0} bin \ outerFile", AppDomain. CurrentDomain. BaseDirectory. ToString ());
This code actually may have a problem, because it is suspected that you graduated from elementary school didn't, don't know the web site project actual operation for the system tray asp.net temp directory, directly to the physical path might also is beyond the scope of the web server permissions management
CodePudding user response:
According to the big though moral emperor supreme instructions1. We can't tell you, path problem
The