This article describes Visual Studio support for debugging ASP.NET Core apps running behind IIS on Windows Server. This topic walks through enabling this feature and setting up a project.
- ASP.NET and web development workload
- .NET Core cross-platform development workload
- X.509 security certificate
- Navigate to Control Panel > Programs > Programs and Features > Turn Windows features on or off (left side of the screen).
- Select the Internet Information Services check box.
The IIS installation may require a system restart.
IIS must have a website configured with the following:
- A host name that matches the app’s launch profile URL host name.
- Binding for port 443 with an assigned certificate.
For example, the Host name for an added website is set to “localhost” (the launch profile will also use “localhost” later in this topic). The port is set to “443” (HTTPS). The IIS Express Development Certificate is assigned to the website, but any valid certificate works:
If the IIS installation already has a Default Web Site with a host name that matches the app’s launch profile URL host name:
- Add a port binding for port 443 (HTTPS).
- Assign a valid certificate to the website.
Enable development-time IIS support in Visual Studio
- Launch the Visual Studio installer.
- Select the Development time IIS support component. The component is listed as optional in the Summary panel for the ASP.NET and web development workload. The component installs the ASP.NET Core Module, which is a native IIS module required to run ASP.NET Core apps behind IIS in a reverse proxy configuration.
Configure the project
For a new project, select the check box to Configure for HTTPS in the New ASP.NET Core Web Application window:
In an existing project, use HTTPS Redirection Middleware in
Startup.Configure by calling the UseHttpsRedirection extension method:
public void Configure(IApplicationBuilder app, IHostingEnvironment env) if (env.IsDevelopment()) app.UseDeveloperExceptionPage(); else app.UseExceptionHandler("/Error"); app.UseHsts(); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseMvc();
IIS launch profile
Create a new launch profile to add development-time IIS support:
- For Profile, select the New button. Name the profile “IIS” in the popup window. Select OK to create the profile.
- For the Launch setting, select IIS from the list.
- Select the check box for Launch browser and provide the endpoint URL. Use the HTTPS protocol. This example uses
- In the Environment variables section, select the Add button. Provide an environment variable with a key of
ASPNETCORE_ENVIRONMENTand a value of
- In the Web Server Settings area, set the App URL. This example uses
- Save the profile.
Alternatively, manually add a launch profile to the launchSettings.json file in the app:
"iisSettings": "windowsAuthentication": false, "anonymousAuthentication": true, "iis": "applicationUrl": "https://localhost/WebApplication1", "sslPort": 0 , "profiles": "IIS": "commandName": "IIS", "launchBrowser": true, "launchUrl": "https://localhost/WebApplication1", "environmentVariables": "ASPNETCORE_ENVIRONMENT": "Development"
Run the project
In the VS UI, set the Run button to the IIS profile and select the button to start the app:
Visual Studio may prompt a restart if not running as an administrator. If prompted, restart Visual Studio.
If an untrusted development certificate is used, the browser may require you to create an exception for the untrusted certificate.