C # Port Number of the connection string Database Server

Source: Internet
Author: User
Tags mssql server

The normal database connection string configuration, which is when the MSSQL server port is 1433 (default.

The normal database connection string configuration, which is when the MSSQL server port is 1433 (default.


<Add key = "article" value = "Server =.; uid = admin; Pwd = admin; database = dB;"> </Add>

But sometimes, for the sake of database server security, this port will be changed to another port, and the following error may be reported when you connect to the database again:

An error occurred while establishing a connection with the server. When you connect to SQL Server 2005, the default setting does not allow remote connection to SQL Server may cause this failure. (Provider: named pipeline providesProgram, Error: 40-unable to open the connection to SQL Server)

In this case, you only need to add the port number:


<Add key = "article" value = "Server =., port number; uid = admin; Pwd = admin; database = dB;"> </Add>

Port modification method:

"Start" --> "server network utility" --> TCP/IP --> default port: 2433 (other options are acceptable)

StateServer session management

Set the mode attribute to StateServer, that is, store session data to a separate memory buffer, and then control the buffer by running Windows Services on a separate machine. The full name of Status Service is "Asp.net State Service (aspnet_state.exe), which is configured by the stateconnectionstring attribute in the web. config file. This attribute specifies the server where the service is located and the port to be monitored:

stateconnectionstring =" TCPIP = myserver: 42424 "

cookieless =" false "timeout =" 20 "/>

<Mode = "StateServer">

In this example, the status service runs on port 42424 (default port) of a machine named myserver. To change the port on the server, edit the port value in the HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ aspnet_state \ Parameters registry. Obviously, the advantage of using status service is process isolation and can be shared in Web farm. In this mode, session state storage does not depend on the failure or restart of the IIS process. However, once the State Service is suspended, all session data will be lost. In other words, the status service does not support persistent data storage as SQL Server does; it only stores data in the memory.

Unable to send a session Status request to the session Status server. Make sure that ASP. NET State Service (ASP. NET State Service) is started and 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 value 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 changed to 1, remote connection is acceptable ), the status server connection string must use "localhost" or "127.0.0.1" as the server name.

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.