Unable to issue a session-state request to the session-state server. Ensure that the ASP. NET State Service (ASP) is started

Source: Internet
Author: User
Tags session id stack trace

Session state requests cannot be made to the session-state server. Make sure that the ASP. NET State Service (ASP) is started and that the client port is the same as the server port. If the server is on a remote computer, please check the hkey_local_machine\system\currentcontrolset\services\aspnet_state\parameters\ The value of allowremoteconnection to ensure that the server accepts remote requests. If the server is on the local computer and the registry value mentioned above does not exist or is set to 0, the state server connection string must use "localhost" or "127.0.0.1" as the server name.

The error is as follows:
Exception Details: System.Web.HttpException: Unable to issue a session state request to the session-state server. Make sure that the ASP. NET State service is started and that the client and server ports are the same. If the server is on a remote computer, please check the hkey_local_machine\system\currentcontrolset\services\aspnet_state\parameters\ The value of allowremoteconnection to ensure that the server accepts remote requests.

SOURCE Error:

An unhandled exception was generated during the execution of the current WEB request. You can use the following exception stack trace information to determine information about the cause of the exception and where it occurred.

Cause Analysis:
Configuration sessionstate in Web. config has a mode of StateServer, but the server does not have the service switched on.

Workaround:
1.web.config inside the sessionstate mode changed to "InProc";
2. Enable "ASP." In the service

Web. config for sessionstate node configuration, there are four modes of sessionstate: Off,inproc,stateserver,sqlserver.

1,off mode

Literally you can see that this is a closed mode, if the current page does not need the value of the session, in order to reduce the server resources, you can remove the session overhead.

<sessionstate mode= "Off" > or on the page

<%@ page enablesessionstate= "false"%> to close the session.

2.inproc Mode (default mode)

It allows "cookie-free" sessions, as well as storage outside the server
Session data. Asp. NET session state module is configured in the Web. config file as follows:

<sessionstate mode= "InProc" cookieless= "false" timeout= "/>"

In this example, the Mode property is set to InProc (the default), which indicates that the session state is to be stored in memory by ASP.
No cookie is used to pass the session ID. In this way, no cookie or hidden form fields are unnecessary.
So, even if you don't use a form in your Web page, you can join a conversation. But this way, the state of the application will depend on the ASP. NET process, when the IIS process crashes or restarts normally, save the
The status in the process is lost.

3.StateServer Session Management MoS

Set the Mode property to StateServer, which is to store session data in a separate memory buffer and run on a separate machine

Windows services to control this buffer. The status service full name is "ASP." (Aspnet_state.exe), Computer Management-service can see this service, start the service J

It is configured by the stateConnectionString property in the Web. config file. This property specifies the server on which the service resides, and the

Port of view:
<sessionstate mode= "StateServer"
Stateconnectionstring= "tcpip=myserver:42424"
Cookieless= "false" timeout= "/>"

In this example, the State service runs on port 42424 (the default port) of a machine named MyServer. To change on the server

Port, you can edit the port value in the Hkey_local_machine\system\currentcontrolset\services\aspnet_state\parameters registry key.

Obviously, the advantage of using a state service is process isolation and can be shared in a Web farm (site farm). With this mode, session state storage will not

Depending on the failure or restart of the IIS process, all session data will be lost once the state service is aborted. In other words, the state service does not

The data is persisted as SQL Server does, and it simply stores the data in memory.

4 Session Management with SQL Server

Asp. NET also allows session data to be stored in a database server by turning the Mode property into SQL.
In this case, ASP. NET attempts to store session data in the sqlConnectionString attribute (which contains the data source and the logon service

Security credentials required by the server.


In order to configure SQL erver with the appropriate database objects, the administrator also needs to create the ASPState database.
Method is to run the InstallSqlState.sql script in the Windir\microsoft.net\framework\version folder (windir is the service

Windows folder, and version is the installation folder for the. NET Framework version you are using.


To configure a SQL Server, you can run SQL Server-provided command-line tools on the command line Osql.exe

osql-s [Server name]-u [user]-p [Password]-I installsqlstate.sql
For example
Osql-s (local) \netsdk-u sa-p ""-I InstallSqlState.sql

Here the user name must be the SA account on the SQL Server, or another account with equivalent permissions. Interested readers can open the
This script file to understand how ASP. NET implements state management with SQL Server.


To unload these tables and stored procedures, you can use the UninstallSqlState.sql script, similar to the previous method. After you have done the necessary database preparation, change the mode of the sessionstate element in the Web. config file to "SQL Server"
, and specify the SQL connection string. Specific as follows:

mode= "SQL Server"
sqlconnectionstring= "Data source=127.0.0.1; Userid=sa; Password= "

When SQL Server is configured, the application code runs with no difference from InProc mode. Note, however, that because the data is not stored in local memory, objects that store session state need to be serialized and deserialized to pass through the network to the database server and back from the database server. This will of course affect performance. By storing session state in the database, you can effectively balance performance for scalability and reliability, respectively. In addition, you can leverage the SQL Server cluster so that the state store does not rely on a single SQL Server, so that you can provide maximum reliability for your application.

Unable to issue a session-state request to the session-state server. Ensure that the ASP. NET State Service (ASP) is started

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.