Deploy MVC Core To IIS On Windows Server – Step by Step Guide


In this article we are going to discuss how to deploy mvc core to iis on windows server or how to deploy asp.net core application to IIS on windows server. Let’s discuss necessary steps to deploy deploy mvc core to iis on windows server. We have to follow these steps to deploy asp.net core application to IIS on windows server.

Steps to deploy mvc core to iis on windows server

  • Enabling IIS and Required Components.
  • Install .net core web hosting (hosting bundle required version)
  • Install SQL Server and Enable Sever Authentication
  • Publish Application Using Visual Studio
  • Deploy Application to IIS
  • Add SQL Authentication to appsetting.json file
  • Change Application Pool to No Manage Code
  • Set Environment Variables

Enabling IIS and Required Components on Windows Server 2012/2012 R2

To host our asp.net application to IIS on windows server first we need to enable IIS and its required components. By following the given steps, you can also check for all required components to be enabled if your IIS is already enabled. If any of required component is not enabled you can enable it. There is option to allow the installation automatically enable the required IIS components. In some cases, depending on your organization’s security policies, it may be necessary to manually enable the required IIS components.

Follow the given steps to enable IIS and required components on windows Server 2012/2012 R2.

  1. Open Server Manager and click Manage >>> Add Roles and Features. Then Click Next.
  2. Select Role-based or feature-based installation and then click Next.
  3. Select the appropriate server. Local server is selected by default. Click Next.
  4. Enable Web Server (IIS) and click Next.
  5. No additional features are necessary to install the Web Adaptor, so click Next.
  6. On the Web Server Role (IIS) dialog box, click on Next.
  7. On the Select role services dialog box, verify that the web server components listed below are enabled. (All required IIs components given below must be enabled) then Click Next.
  8. Verify that your settings are correct and click Install.
  9. After completion of Installation, click Close to exit the wizard.

Required IIS components

These IIS components satisfy the minimum requirements to run the Web Adaptor. If you have enabled other IIS components, they do not need to be removed.

  • Web Server
    • Common HTTP Features
      • Default Document
      • Static Content
    • Security
      • Request Filtering
      • Basic Authentication
      • Windows Authentication
    • Application Development
      • .NET Extensibility 4.5
      • .NET Extensibility
      • ASP.NET 4.5
      • ASP.NET
      • ISAPI Extensions
      • ISAPI Filters
      • WebSocket Protocol
  • Management Tools
    • IIS Management Console
    • IIS 6 Management Compatibility
      • IIS 6 Metabase Compatibility
    • IIS Management Scripts and Tools
    • Management Service

Install .net core web hosting (hosting bundle required version)

After enabling the IIS and its required components we need to download and install the required webhosting bundle version according to our project. Hosting bundle is very essential to run our published project on IIS.

Install SQL Server and Enable Sever Authentication

You need SQL server, if you are going to deploy a dynamic application which is using SQL Server for application authentication or to store data.

It is necessary to enable SQL server authentication after its installation to enhance SQL database and application security.

Publish Application Using Visual Studio

As we have competed above necessary steps to deploy asp.net core application to IIS, now we need a publish file to deploy on IIS.

Go to Visual studio and open the application which you have to deploy.

Go to Solution explorer, right click on  application name and select publish from context menu.

Select appropriate folder where you want to save the file and publish it.

Deploy Application to IIS

As you have enabled IIS before, just go to IIS (Internet Information Service).

  • In IIS go to connection section >>> Sites.
  • Right click on sites and select Add Website from context menu.
  • Give Site name according to your project name or requirement.
  • Select physical path to C:\inetpub\wwwroot\site_named_folder
  • Set bindings and click on OK. Your site is created in IIS.
  • Now add your publish files to site folder in C:\inetpub\wwwroot.

Add SQL Authentication to appsetting.json file

To add SQL authentication, go to your site folder and and open the file appsetting.json using any code editor or notepad. In connection string add SQL server name, User name and password And save the file. This step is very important to communicate with SQL server.

Change Application Pool to No Manage Code

Now we need to change Application pool to no mange code to run our asp.net  core application on IIS. To do this we have to follow the following steps.

Go to connection section in IIS.

Select Applications Pools, Then Double click on site you are deploying.

Select No Managed Code in .Net CLR version.

Click Ok to finish the setup.

Set Environment Variables

To Set environment variables for the IIS Site, go through the following steps.

  • Open the IIS Manager and select your required website
  • Open “Configuration Editor” from “Management” section of selected site.
  • On “Configuration Editor” window, On the first dropdown (section), select “system.webServer/aspNetCore” and on the second (from), select web.config.
  • Then click on the “environmentVariables” and use the add/remove buttons to configure as you want.
  • You can get environment variable to set by opening, Visual Studio >>> Project you are going to deploy >>> launchsetting.json file in Solution explorer.

Run Your application using your configured Port.

As you have done with all the necessary steps, to deploy mvc core to iis on windows server, Now run the application using the configured domain(IP)and port.

That’s all you have done.

Share With Others:

Add a Comment

Your email address will not be published. Required fields are marked *