.Net Core

From Hostek.com Wiki
Revision as of 04:05, 16 September 2017 by Briana (Talk | contribs) (Created page with "This wiki contains details about running ASP.Net Core under IIS. '''What is ASP.Net Core?''' ASP.Net Core is an open-source cross-platform version of ASP.Net. Due to being...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This wiki contains details about running ASP.Net Core under IIS.


What is ASP.Net Core?

ASP.Net Core is an open-source cross-platform version of ASP.Net. Due to being cross-platform, it does not have access to the full "Base Class Library"(BCL) available in the full Windows .Net Framework. However, Microsoft and the open-source community are actively porting over the most important parts of the BCL so the disparity is getting smaller with each version.


ASP.Net Core Windows Server Hosting Bundle

All of our Shared Windows servers have the "ASP.Net Core Windows Server Hosting Bundle" installed. This IIS module allows ASP.Net Core websites to be hosted behind IIS. All ASP.Net Core sites run their own http webserver named "kestrel" in the background. The IIS module passes information to the ASP.Net Core application letting it know which port it should use and then proxies connections to the kestrel webserver.

NOTE: The "kestrel" webserver used by ASP.Net Core is not designed to be public facing. It is only designed to be used behind another webserver, such as IIS on Windows or nginx on Linux. So even for VPS customers who could technically run ASP.Net Core without IIS, it is recommended to use always use IIS.


Required web.config settings

There are some required web.config settings for the ASP.Net Core application directory that enable the IIS module. Below is an example configuration that will enable ASP.Net Core within a directory:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
 <system.webServer>
   <aspNetCore processPath="dotnet" 
       arguments=".\MyApp.dll" 
       stdoutLogEnabled="false" 
       stdoutLogFile=".\logs\stdout" />
 </system.webServer>
</configuration>

When the 'aspNetCore' configuration element is present, all requests underneath that folder will be forwarded to the ASP.Net Core webserver. This means you may not be able to browse directly to static files underneath that path. However, you can disable this forwarding/proxying in a sub-folder by explicitly removing the aspNetCore handler in the sub-folders web.config file:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
 <system.webServer>
   <handlers>
     <remove name="aspNetCore"/>
   </handlers>
 </system.webServer>
</configuration>


The necessary web.config entries as shown above should be automatically generated by Visual Studio when you use the 'Publish" feature to generate the application files, but it is important to be aware of its need and the possible side-affects.