The pitfalls of ASP. NET website publishing, ASP. NET website publishing
Development tools: VS2010, MVC4.0, and SQLSERVER2008
Servers: Windows server 2012, IIS8, and SQLSERVER2012
1. After the release, each page is very stuck for the first time, 50 seconds or longer, and the second time it is opened quickly.
Cause: the compilation speed is slow, but the release on machines in the VS environment is not so slow.
Solution:
- Use a later version of VS to "pre-compile during release ";
- Use the Application Initialization function of IIS8
1. Use VS2017 to "pre-compile during release"
An error occurred during release:
The Section registered as allowDefinition = 'machinetoapplication' outside the application level is incorrect. This error may occur if the virtual directory is not configured as an application in IIS.
Solution: comment out the following code in web. config at release.
<!--<authentication mode="Forms"> <forms loginUrl="~/Account/Login" timeout="2880" /></authentication>-->
2. Use the Application Initialization function of IIS8
Http://jingyan.baidu.com/article/c843ea0bb6c13877931e4a2e.html
Ii. frequent loss of ASP. NET sessions
Symptom: the session is lost about 30 seconds after logon. You need to log on again.
Solution: ASP. NET has several session Status modes. The default mode is "InProc mode" and changed to "StateServer mode". The problem is solved.
1. off Mode
Close the Session.
You can disable the Session in the <system. Web> section of the web. Config file:
<sessionState mode="off">
To disable a Session on a page, you can add the following on the page:
<%@ Page EnableSessionState="false" %>
2. InProc mode (default mode)
If SessionState Mode is not configured in the Web. config file, the default Mode is InProc.
To customize parameters in InProc mode, you need to write the Web. config file, for example:
<sessionState mode="InProc" cookieless="false" timeout="20" />
Cookieless sets whether to allow the use of cookies, and timeout sets the timeout time, in minutes.
The InProc mode depends on ASP. NET processes. When the IIS process crashes or restarts, the session Status stored in the process will be lost.
3. StateServer mode
In StateServer mode, session data is stored in a separate memory buffer. NET State Service (enabled in windows Service) to control this buffer, you need to set stateConnectionString:
<sessionState mode="StateServer" stateConnectionString="tcpip=127.0.0.1:42424" timeout="20" />
The StateServer mode is independent of the IIS process. the restart of the IIS application does not affect session data.
4. SQLServer Mode
Use SQL Server to save the Session. Even if IIS is restarted, the Session will not be lost. Create an ASPState database first. The specific method can be queried online.