This is only short tutorial about how to upload asp.net core in IIS. Thanks to Rick Strahl for writing great tutorial about publishing asp.net core.
ASP.NET Core with IIS
With the ASP.NET core, the application is NOT hosted inside of an IIS worker process but rather runs as a separate process (like a Console application) that runs its own Web server using the Kestrel component. It’s fast and functional in getting network requests into your application, but it’s ‘just’ a raw Web server. It does not include Web management services as a full-featured server like IIS and NGNIX does.
ASP.NET Core applications are standalone Console applications invoked through the dotnet runtime command. They are not loaded into an IIS worker process, but rather loaded through a native IIS module called AspNetCoreModule
that executes the external Console application.
The AspNetCoreModule has to be installed on your server and is part of the ASP.NET Core Server Hosting Bundle.
Once you’ve installed the hosting bundle (or you install the .NET Core SDK on your Dev machine) the AspNetCoreModule is available in the IIS native module list:
The AspNetCoreModule’s job is to ensure that your application gets loaded when the first request comes in and that the process stays loaded if for some reason the application crashes. Once running, incoming Http requests are handled by this module and then routed to your ASP.NET Core application.
If you run on Windows you will likely want to run Kestrel behind IIS to gain infrastructure features like port 80/443 forwarding via Host Headers, process lifetime management and certificate management to name a few.
While the IIS Site/Virtual still needs an IIS Application Pool to run in, the Application Pool should be set to use No Managed Code. Since the App Pool acts merely as a proxy to forward requests, there’s no need to have it instantiate a .NET runtime.
The AspNetCoreModule is configured via the web.config
file found in the application’s root
<?xml version="1.0" encoding="utf-8"?> <configuration> <!-- Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380 --> <system.webServer> <handlers> <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" /> </handlers> <aspNetCore processPath="dotnet" arguments=".\yourapp.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" /> </system.webServer> </configuration>
If the above config does not work try with the following config which you will be getting when you published in the local system folder.
<?xml version="1.0" encoding="utf-8"?> <configuration> <!-- Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380 --> <system.webServer> <handlers> <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" /> </handlers> <aspNetCore processPath=".\yourapp.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" /> </system.webServer> </configuration>
Note that when you open the config which was created as a result of publishing the application, you will find AspNetCoreModule (marked bold in the above config)as AspNetCoreModuleV2. Change it to AspNetCoreModule
IIS Identity and Permissions
You might also have to tweak the IIS App Pool Identity to something other than the default ApplicationPoolIdentity in order to ensure that your application has access to resources it needs to run. Try starting with NETWORKSERVICE and then move to a Custom Account that matches the actual rights required by the application.
Choosing Your ASP.NET Core Hosting Provider
Sometimes it is quite hard to find reliable, cheap hosting that support ASP.NET Core. We know that is is important that reliable web host really impact to our business, moreover if we really depend on our site. We have made review about ASP.NET Core hosting recommendation that you can consider if want to host ASP.NET Core. Just check the link!