Application configuration
ASP.NET Core Debug IIS Visual Studio

How to Configure Visual Studio for IIS Debugging of .NET Core Web Applications

Welcome to todays post.

In todays post, I will be showing how to configure Visual Studio to allow debugging of .NET Core web applications hosted under IIS.

In VS 2017, there is currently build-in support for debugging IIS, but only under IIS Express.

I will show how to create a runtime profile that will allow a .NET Core web application to be debugged within the VS 2017 IDE.

First, start by opening the project properties for your .NET Core application.

Click on the Debug side tab. The following property page will show the default IIS Express profile:

Click on New…

The Debug profile page shows.

Enter a new profile name.

Name the profile IIS.

The remainder of the Debug page shows.

Enter values for the Launch browser URL, select Launch browser as shown:

In the environment variables section, enter a key and value pair of ASPNETCORE_ENVIRONMENT and Development as shown below:

Save the debug settings.

After saving the debug settings, the launchSettings.json file will be updated as shown below with the new IIS profile settings:

To run the application, locate the run button and drop-down to select the IIS profile as shown:

After running, you may see the following error dialog.

Click Yes to change the disk mapping to the URL.

Wait a few minutes for the IIS to be provisioned.

Once the provisioning has completed and run and your application has launched, the first application breakpoint (if set) will be hit as shown:

You have successfully configured the .NET Core web application for IIS debugging!

Another thing to note is that once the Web application is set for debugging, the application debug location is mapped to the project disk location as shown:

When you wish to revert the Web application back to IIS hosting, the path can be reverted as shown:

If you get the following error when attempting to run the Web API project from IIS settings:

Then open the launchSettings.json file and add the lines below showing the key / values under the “iisSettings” element:

"iis": {
      "applicationUrl": "http://localhost/BookLoan.Loan.API",
      "sslPort": 0
    },

with the applicationUrl and sslPort defined with your application site URL and port.

Your launch settings should look as follows:

  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iis": {
      "applicationUrl": "http://localhost/BookLoan.Loan.API",
      "sslPort": 0
    },
    "iisExpress": {
      "applicationUrl": "http://localhost:63054/",
      "sslPort": 0
    }
  },

For more detailed treatment of this topic, you can refer to the Microsoft web page:

That’s all for today’s post.

I hope this post has been useful and informative.

Social media & sharing icons powered by UltimatelySocial