Overview
Unlike the ASP. NET era, ASP. Core is no longer hosted by the IIS worker process (w3wp.exe), but is run with a self-hosted Web server (Kestrel), and IIS is a reverse proxy role forwarding request to an ASP. NET Core program that Kestrel different ports. The received request is then pushed to the middleware pipeline, and the HTTP response data is then written back to IIS after processing your request and related business logic, eventually to different clients (browsers, apps, clients, etc.). While the configuration files and procedures will be slightly adjusted, the most important role in the middle is aspnetcoremodule, which is one of the IIS modules, the request is immediately forwarded to IIS, and quickly redirected to the ASP. So at this point we don't need to set up the application pools to host our code, it is only responsible for forwarding the request.
Before you deploy, make sure that you have Aspnetcoremodule managed modules installed on your IIS, and if not, click here to download and install
One, install IIS
1. In Control Panel → program → enable or disable Windows features → Tick Internet Information Services and the IIS management console under Web management tools
Ii. release of the project
1. Publish our last built ASP. NET Core API project, then select IIS, create a new release configuration
2. Publish method Select the file system and set a publishing path
3, the configuration file can be based on your online, offline environment to choose, because it is based on. NET Core, so the target framework is netcoreapp1.1, and then save the publication to
4, of course, you can also be based on the CLI Publish command to publish, just switch to the LIGHT.API root directory, enter the following command to
dotnet Publish--framework Netcoreapp1. 1 " E:\Publish " --configuration Release
The framework represents the target framework, and the output represents the directory folder to publish to, the configuration file, which is equivalent to the actions we publish through the manager above,
Third, add a Web site in IIS
1, add a website, set the name, and point the path to the folder you just published, and then start the site
2. Set the. NET CLR version of the application pool to "unmanaged code" because just now, IIS is the role of a reverse proxy and does not need it to host code
3, OK, done, browse our website.
At this point my heart is broken, there is no useful information, it seems you can only see the application's running log.
4. Set the logging mode for IIS to log files and ETW events
5. Revisit the website, then open the Windows Application log and you will see a message like this. This means that your application has been started by the PID 3236 process and is listening on the 25636 port.
I opened the task manager and looked at it and said it was right. Should be all normal to Ah, then why visit the site is 404.
Tangled up for a while, the original is because the site does not automatically redirect to the/swagger/ui page, re-visit: Http://192.168.1.105/swagger/ui, you will see the familiar picture
6, the last point, in fact, you can also use the CLI to run your published programs, switch to your publishing folder, enter the following command:
Dotnet Light.API.dll
See this hint, then you are successful. Try a visit: Http://localhost:5000/swagger/ui
And then you look back at the task Manager, and then there's another dotnet process.
Written in the last
At this point, the entire IIS build has been completed, do not know whether you have a harvest. Next I don't know what kind of pit it will have to post it on Linux. Anyway, every step you take, looking back, is worth it!
Deploy your ASP. NET Core project on IIS