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.

Source: Internet
Author: User
Tags 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 is connected

2011-03-16 13:55:52  |  Category: asp | Tags: | font size big medium small Subscribe

Description:An unhandled exception occurred during the execution of the current WEB request. Check the stack trace information For more information about the error and the source of the error in your code.

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 (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.

Source Error:

执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。

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";

Web. config inside:
<sessionstate
Mode= "InProc"
Stateconnectionstring= "tcpip=127.0.0.1:42424"
sqlconnectionstring= "Data Source=127.0.0.1;user id=sa;password="
Cookieless= "false"
Timeout= "20"
/>
You are not using "stateserver", if yes, please refer to:
Using StateServer mode

Make sure that the ASP. NET State service is running on a remote server that stores session-state information. The service is installed with ASP. <drive>:\program Files\asp.net\premium\version\aspnet_estate.exe is available by default 。
In the application's Web. config file, set mode=stateserver and set the stateConnectionString property, for example stateconnectionstring= "Tcpip=sarat h:42424 ".

Or
2. Enable "ASP." In the service

In the Administrative Tools, "service" starts "ASP." This method I have tried, can solve the problem.

ways to open the ASP. NET State Service services in a Windows 7 system

  Control Panel, programs and features, "Open or Close Windows Features" dialog box, Internet Information Services, World Wide Web services, application development features, ASP.
Control Panel--Programs-> Programs and Features-Turn Windows Features on or off-> Internet informatio n Services, World Wide Web Services, Application development Features, ASP.

When the ASP. NET option is checked, the ASP. NET state S is present in the Control Panel, System and Security, administrative Tools and Services service Ervice Services.

In the Properties dialog box, set the startup type to Automatic (Automatic), and finally start. (Note: Windows XP systems are set up in Add and Remove Programs in Control Panel)

3. This is possible, but there is no understanding of why this should be done. Later on the Internet to find one to know the reason for the truth.

Introduction to the session model
What is the session? In simple terms, the server gives the client a number. When a WWW server is running, there may be a number of users browsing the Web site that is being shipped on this server. When each user establishes a connection to this WWW server for the first time, he establishes a session with the server, and the server automatically assigns it a SessionID to identify the user's unique identity. This SessionID is a 24-character string randomly generated by the WWW server, and we'll see what it looks like in the experiment below.

The only SessionID is of great practical significance. When a user submits a form, the browser automatically attaches the user's SessionID to the HTTP header information (this is the browser's automatic function, which the user will not perceive), and when the server finishes processing the form, the result is returned to the user of SessionID. Imagine, if there is no SessionID, when two users register at the same time, how the server can know exactly which user submitted which form. Of course, SessionID has many other functions that we will mention later.

In addition to SessionID, a lot of other information is included in each session. However, for programs that write ASP or ASP. NET, the most useful thing is to access the asp/asp. NET has built-in session objects that store individual information for each user. For example, we would like to know about the users who visit our website and browse several pages, and we may add them to each page that the user may visit:

<%
If Session ("pageviewed") = "Then
Session ("pageviewed") = 1
Else
Session ("pageviewed") = Session ("pageviewed") + 1
End If
%>

The following sentence lets the user know that they have browsed several pages:


<%
Response.Write ("Viewed" & Session ("pageviewed") & "pages")
%>


Some readers may ask, "This is a session (".. ") that looks like an array. Where did it come from? Do I need to define it? In fact, this session object is the built-in object of the WWW server with ASP interpretation capability. In other words, the ASP system has already defined the object for you, you just need to use it. where session ("..") In the.. Just like the variable name, Session ("..") The $$ in =$$ is the value of the variable. All you have to do is write a word that you can access on each page of the user. The value in the variable.

In fact, the ASP built a total of 7 objects, there is session, application, cookies, Response, Request, server and so on. In other server-side scripting languages such as JSP, PHP and so on, there are similar objects, just called or the use of the method is not the same.

The defect of the function of ASP session
Currently, ASP developers are using the session as a powerful feature, but in their use of the process found that the ASP session has the following defects:

Process dependencies: The ASP session state is stored in the IIS process, that is, the Inetinfo.exe program. So when the Inetinfo.exe process crashes, the information is lost. In addition, restarting or shutting down the IIS service can result in the loss of information.
Limitations of the session state usage scope: When a user accesses a website from one site to another, the session information is not migrated in the past. For example: Sina Web site may have more than one WWW server, a user login to the various channels to browse, but each channel is on a different server, if you want to share session information in these WWW server how to do?
Cookie dependency: In fact, the client's session information is stored and cookie, if the client completely disables the cookie function, he will not be able to enjoy the function provided by the session.
In view of the above shortcomings of ASP session, Microsoft Designers in the design and development of the ASP. NET session was improved, completely overcome the above shortcomings, making the ASP. NET session becomes a more powerful function.

Introduction to the Web. config file
Some ASP. NET programmers say: Web. config file? I have never heard of Ah, but I write the program can not also be very normal operation? Yes, you're right, there's no Web. config file program that works. However, if you do a large web site, you need to do some overall configuration of the whole site, such as the whole site of the page in which language written, the site's security authentication mode, session information storage, etc., then you need to use the Web. config file. Although some of the options in the Web. config file can be configured through IIS, the configuration in IIS is overwritten if there is a corresponding setting in Web. config. Moreover, the greatest convenience of the Web. config file is that the settings in Web. config can be accessed in an ASP. NET page by calling the System.Web namespace.

There are two types of Web. config, the server configuration file and the website application configuration file, both of which are named Web. config. In this configuration file, you will save a series of information that is written in the language of the current IIS server, the application Security authentication mode, and the session information storage method. This information is saved using XML syntax, and if you want to edit it, you can use a text editor.

Where the server configuration file works for all applications in all sites under the IIS server. In the. NET Framework 1.0, the Web. config file for the server is present: \winnt\microsoft.net\framework\v1.0.3705.

Web application configuration file. config files are saved in each Web application. For example: The root directory of the current Web site \inetpub\wwwroot, and the current Web application is MyApplication, the Web application root should be: \inetpub\wwwroot\myapplication. If your site has and has only one Web application, the root directory of the application is generally \inetpub\wwwroot. If you want to add a Web application, add a virtual directory with the application start point in IIS. Files and directories in this directory will be treated as a Web application. However, the Web application is not generated for you by using IIS. If you want to create a Web application with a. config file, you will need to use Visual Studio.NET, creating a new Web Application project.

The Web application's configuration file, Web. config, is optional and dispensable. If not, each Web application uses the server's Web. config profile. If so, the corresponding values in the server Web. config configuration file are overwritten.

In ASP. NET, the Web. config modification is saved automatically immediately, and no longer needs to be restarted as soon as the configuration file in ASP is modified to take effect.

Session configuration information in the Web. config file
After opening the configuration file for an application, Web. config, we will find the following paragraph:

<sessionstate
Mode= "InProc"
Stateconnectionstring= "tcpip=127.0.0.1:42424"
sqlconnectionstring= "Data source=127.0.0.1; Trusted_connection=yes "
Cookieless= "false"
Timeout= "20"
/>

This section is about configuring how the application stores session information. The following operations are mainly for this section of the deployment. Let's take a look at the meaning of the content contained in this section of the configuration. The syntax for the sessionstate node is this:

<sessionstate mode= "off| inproc| stateserver| SQL Server "
Cookieless= "True|false"
timeout= "Number of minutes"
Stateconnectionstring= "Tcpip=servername:port"
sqlconnectionstring= "SQL connection string"
statenetworktimeout= "Number of seconds"
/>


Required properties are

Property Options Description
Mode settings where to store the session information
OFF is set to do not use the session function
The InProc is set to store the session inside the process, which is the default value for storage in ASP.
The StateServer is set to store the session in a separate state service.
SQL Server settings stores the session in a

Related Article

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.