Asp. NET site when publishing those pits, be careful, why the site after the first time each page opened is a card? How to solve the frequent loss of ASP. Have a certain reference value, interested in small partners can refer to
Development tools: vs2010,mvc4.0,sqlserver2008
Server: Windows Server 2012,iis8,sqlserver2012
First, after the release, each page opened very card, 50 seconds or longer, the second time opened soon
Estimated cause: Slow compilation, but not on machines with VS environment
Workaround:
Use a high version of VS, "precompile during publishing", use IIS8 's application initialization feature 1. Using VS2017 to "precompile during publishing"
An error was encountered when publishing:
It is an error to use a section registered as allowdefinition= ' machinetoapplication ' outside the application level. This error can be caused if the virtual directory is not configured as an application in IIS.
Workaround: Comment The following code in Web. config at publish time
<!--<authentication mode= "Forms" > <forms loginurl= "~/account/login" timeout= "2880"/></ Authentication>-->
2. Using IIS8 's application initialization function
Asp. NET site first time access slow solution
Ii. frequent loss of ASP.
Symptom: After 30 seconds of Login, the session is lost and needs to be logged in again.
WORKAROUND: ASP. NET has several session state modes, the default is "InProc mode", changed to "StateServer mode", the problem is dismissed.
1. Off mode
The session is closed.
Full station close session can be written in the <system.web> section in the Web. config file:
<sessionstate mode= "Off" >
To close a session on a page, you can add:
<%@ page enablesessionstate= "false"%>
2. InProc mode (default mode)
If sessionstate mode is not configured in the Web. config file, the default is InProc mode.
If you want to customize the parameters of the InProc mode, you need to write the Web. config file, for example:
<sessionstate mode= "InProc" cookieless= "false" timeout= "/>"
cookieless sets whether to allow setting the time-out in minutes without using cookie,timeout.
The InProc mode relies on ASP. NET process, the session state saved in the process is lost when the IIS process crashes or restarts.
3. StateServer mode
The StateServer mode is to store session data in a separate memory buffer, which is controlled by a Windows service "ASP." (which needs to be opened in Windows Services) to control this buffer. You need to set stateConnectionString:
<sessionstate mode= "StateServer" stateconnectionstring= "tcpip=127.0.0.1:42424" timeout= "/>"
When using StateServer mode, all classes that need to be saved in the session are given the serializable features:
[Serializable]
public class SomeClass {}
The advantage of the StateServer mode is that it is independent of the IIS process, and the restart of the IIS application does not affect session data.
4. SQL Server Mode
Use SQL Server to save the session, even if IIS restarts, the session will still not be lost. The ASPState database needs to be created first. Specific methods can be queried on the Internet.
The above is the whole content of this article, I hope that everyone's learning has helped, but also hope that we support the script home.