Normal database connection string configuration, which is the case where the MSSQL server port is 1433 (default).
<add key= "Article" value= "server=.; uid=admin;pwd=admin;database=db; " ></add>
But sometimes, for the database server to be secure, the port is changed to something else, and then connecting to the database may report the following error:
An error occurred while establishing a connection to the server. When you connect to SQL Server 2005, this failure may be caused by SQL Server not allowing remote connections under the default settings. (provider: Named pipe provider, error:40-cannot open a connection to SQL Server)
You just need to add the port number:
<add key= "Article" value= "server=., port slogan; uid=admin;pwd=admin;database=db;" ></add>
Port Modification Method:
"Start"--> "Server Network Utility"-->tcp/ip--> default port: 2433 (other can also)
StateServer Session Management
Set the Mode property to StateServer, which means that the session data is stored in a separate memory buffer, and then the Windows service running on a separate machine controls the buffer. The full name of the status service is "ASP.net State Services" (Aspnet_state.exe), which is configured by the stateConnectionString attribute in the Web.config file. This property specifies the server on which the service resides and the ports to monitor:
<sessionstate mode= "StateServer"
Stateconnectionstring= "tcpip=myserver:42424"
Cookieless= "false" timeout= "/>"
In this example, the State service runs on a 42424 port (the default port) of a machine named MyServer. To change ports on the server, edit the port value in the Hkey_local_machine\system\currentcontrolset\services\aspnet_state\parameters registry key. Obviously, the advantage of using state services is process isolation, which can be shared in the Web farm. With this mode, session state storage will not depend on the failure or restart of the IIS process, however, all session data will be lost once the status service is aborted. In other words, the State service does not persist data as SQL Server does; it simply stores the data in memory.
Unable to issue a session-state request to the session-state server. Make sure that the ASP.net state Service (asp.net) is started and that the client port is the same as the server port. If the server is on a remote computer, check
Hkey_local_machine\system\currentcontrolset\services\aspnet_state\parameters\allowremoteconnectio
N to ensure that the server accepts remote requests. If the server is located on the local computer and the registry value mentioned above does not exist or is set to 0 (if you accept a remote connection if you change to 1), the state server connection string must use "localhost" or "127.0.0.1" as the server name.