Home >Backend Development >C#.Net Tutorial >Share the problems and solutions encountered when publishing two ASP.NET websites

Share the problems and solutions encountered when publishing two ASP.NET websites

Y2J
Y2JOriginal
2017-04-28 10:27:572189browse

Be careful about the pitfalls when publishing an ASP.NET website. Why does every page freeze when you first open it after the website is published? How to solve the frequent loss of ASP.NET sessions? It has certain reference value. Interested friends can refer to

Development tools: VS2010, MVC4.0, SQLSERVER2008

Server: Windows server 2012, IIS8, SQLSERVER2012

1. After publishing, each page is stuck for 50 seconds or more when it is opened for the first time. However, it is very fast the second time it is opened.

Estimated reason: slow compilation speed , but publishing on a machine with a VS environment is not so stuck.

Solution:

Use a higher version of VS, "precompile during release"; use the Application Initialization function of IIS8 1. Using VS2017 "Precompile during release"

I encountered an error when publishing:

It is an error to use a section registered with allowDefinition='MachineToApplication' outside the application level. This error can be caused if the virtual directory is not configured as an application in IIS.

Solution: Comment the following code in web.config when publishing


<!--<authentication mode="Forms">
 <forms loginUrl="~/Account/Login" timeout="2880" />
</authentication>-->

2. Use Application Initialization function of IIS8

Solution to slow first access to ASP.NET website

2. ASP.NET session frequent loss problem

Symptom: The session is lost about 30 seconds after logging in, and you need to log in again.

Solution: ASP.NET has several session state modes. The default is "InProc mode". Change it to "StateServer mode" and the problem will be solved.

1. off mode

means closing the Session.

To close the session for the whole site, you can write in the 2dc15ec6bc814c3aa45b55d017848bed section in the Web.Config file:

2455e49983024f8ccf8b732f0adf21a6

To close the Session on a page, you can add on the page:

b26760169218e5c3db07206d05078e57

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 InProc mode, you need to write the Web.config file, for example:

2bc4869001950b4c2e53e750a8859340

When using the StateServer mode, all classes that need to be saved in the Session must be serializable:

[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 the session data.

4. SQLServer mode

Use SQL Server to save the Session. Even if IIS is restarted, the Session will not be lost. You need to create the ASPState database first. Specific methods can be found online.

The above is the entire content of this article. I hope it will be helpful to everyone’s study. I also hope that everyone will support Script House.

The above is the detailed content of Share the problems and solutions encountered when publishing two ASP.NET websites. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn