Deploy .Net Core application to IIS: Step by step guide

In this post, i will be able to make a case for the way to host\deploy your .Net Core 2.0 application to IIS.

prerequisite:

  • Visual studio 2017 community edition
  • .Net Core 2.0 SDK
  • Make sure you have enabled the Web Server (IIS) role and established the role services

Install .NET Core Windows Server Hosting Bundle

Since .Net Core could be a new framework, at this moment IIS isn’t awake to the way to run .Net Core applications. therefore we’d like to tell IIS to line up associate degree surroundings for the .Net Core applications.

For this, we’d like to put in .Net Core Windows Server Hosting bundle which is able to install the .NET Core runtime, libraries, and also the ASP.NET Core module for IIS.

Please note that this can be a awfully necessary step and you need to install the bundle before you publish the applying on IIS.

Wait till the installation is over:

Once the installation is completed, either restart your system or run below commands in sequence in command prompt:

  • net stop was /y
  • net start w3svc

The first command will stop the World Wide Web publishing service and the second command will start the service again.

Create the Web application using .Net Core 2.0 template in VS 2017

Once you have all these installed, open your Visual Studio 2017 -> Create New Project -> Select Core Web application:

Click on Web Application in next window and then click on Ok:

Visual Studio will create a well-structured application for you.

Right click on the solution and click on Publish:

In next window, click on Folders and give the folder path. I created Publish folder under wwwroot folder:

It will publish the application on the above-mentioned path:

Create Website on IIS

Open your IIS Manager and add new website:

Now go to Application Pools panel, open the Edit Application Pool window by right-clicking on the website’s app pool and selecting Basic Settings and set .NET CLR version to No Managed Code:

Check if .Net Core Windows Server Hosting bundle is installed properly

Next step is to check whether the hosting bundle which we installed earlier is installed properly or not.

For this click on Modules(in IIS Manager) of your newly created website and search for AspNetCoreModule. If it is available, it indicates that IIS is now aware of how to run a .Net Core application.

You might be wondering what is Asp .Net Core Module?

  • ASP.NET Core Module lets you run ASP.NET Core applications on IIS for what it’s good for i.e. security, manageability, and lots more
  • On the other hand, ASP.NET Core Module lets you run ASP.NET Core applications using Kestrel for what it’s good at for example being really fast
  • Thus it is getting the benefits of both technologies at once
  • Asp .Net Core Module handles all incoming traffic to IIS and acts as the reverse proxy that knows how to hand the traffic off to your ASP.NET Core application

You may have noticed that when we published the code to a particular folder, a web.config was created in which you can see aspNetCore under Handler section as below. This is only used when deploying your application to IIS and It registers the AspNetCoreModule as an HTTP handler.

<?xml version="1.0" encoding="utf-8"?> <configuration> <system.webServer> <handlers> <strong><add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" /></strong> </handlers> <aspNetCore processPath="dotnet" arguments=".\NeelCorePublishIIIS.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" /> </system.webServer> </configuration>

That is it.

Just load your IIS site and it should load just fine:

Now the application is hosted on IIS.

No #1 Recommended ASP.NET Hosting ASPHostPortal.com

ASPHostPortal.com  is the leading provider of Windows hosting and affordable ASP.NET Hosting. ASPHostPortal proudly working to help grow the backbone of the Internet, the millions of individuals, families, micro-businesses, small business, and fledgling online businesses. ASPHostPortal has the ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2015, .NET Core, ASP.NET MVC Core, Silverlight 6 and Visual Studio Lightswitch, ASPHostPortal guarantees the highest quality product, top security, and unshakeable reliability, carefully chose high-quality servers, networking, and infrastructure equipment to ensure the utmost reliability.

Rate this post