Asp.net core manages IIS on windows for detailed steps, coreiis
Summary
In a recent project, I tried to use asp.net core for development. During deployment, considering the existing hardware, it can only be deployed on windows, but not on linux servers. I won't talk much about it below. Let's take a look at the detailed introduction.
Precautions for deployment
Enable iis and Kestrel in code
public class Program { public static void Main(string[] args) { BuildWebHost(args).Run(); } public static IWebHost BuildWebHost(string[] args) => WebHost.CreateDefaultBuilder(args) .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup<Startup>() .UseApplicationInsights() .Build(); }
Install on the server
. NET Core Windows Server hosting bundle
The. NET Core runtime,. NET Core library, and ASP. NET Core module can be installed in the bundle. This module creates a reverse proxy between IIS and the Kestrel server. If the system does not have an Internet connection, first obtain and install Microsoft Visual C ++ 2015 Redistributable, and then install the. NET Core Windows Server hosting bundle.
Restart the system, or execute net stop was/y and net start w3svc from the command prompt. Restart IIS to select the system PATH changes made by the installer.
Release
Use vs to publish or use commands. Because vs2017 is used for development, vs is directly released.
Create a site on the server
Modify the application pool CLR to No Managed Code
You can create a sub-site test
Make sure that the process model identity has the appropriate permissions.
If you change the default ID ("Process Model"> "ID") of the application pool from ApplicationPoolIdentity to another ID, verify that the new ID has the required permissions, you can access Application folders, databases, and other required resources. For example, the application pool requires the read and write permissions on folders so that the application can read and write files.
Common Errors
If you access through an ip address or port, Error 500 is reported, but dotnet \ xxxxx is used on the server. dll can start kestrel and can be accessed through http: \ localhost: 5000. Generally, you can modify the site directory permission to solve the problem. At least read and write permissions.
For other errors, see
Https://docs.microsoft.com/zh-cn/aspnet/core/host-and-deploy/iis/troubleshoot
Summary
The above is all the content of this article. I hope the content of this article has some reference and learning value for everyone's learning or work. If you have any questions, please leave a message to us, thank you for your support.