Is there any way to debug an ASP.NET Core web application while running under IIS?
I'm running under IIS because I need it to be available over SSL on port 443.
dotnet.exe
and press AttachNote: If you see several dnx.exe processes, choose the one with IIS user in column username. By default it is "IIS APPPOOL{your app pool name}"
P.S. If you see dotnet process with empty username, run Visual studio as Administrator
With ASP.Net Core 1.0.0 you must attach to "{youprojectnamet.exe}". E.g. if you project has name "Web", you must attach to "Web.exe" Also you can find name of the executive in the following section of web.config
<system.webServer>
<aspNetCore processPath=".\Web.exe" />
</system.webServer>
Prerequisite: Add "Development time IIS support" to your existing Visual Studio installation. Follow the next link: https://blogs.msdn.microsoft.com/webdev/2017/07/13/development-time-iis-support-for-asp-net-core-applications/
1. In Visual Studio 2017 create "ASP.NET Core Web Application" with name "MvcMovie".
1.1. Open "MvcMovie" project Properties.
1.1.2. Go to "Debug" tab and set(if not):
1.1.2.1. "Profile:" "MvcMovie".
1.1.2.2. "Launch:" "IIS"
1.1.2.3. (checked)"Launch browser:" "https://localhost"
1.1.2.4. "Environment variables:" | Name: "ASPNETCORE_ENVIRONMENT" | Value: "Development" |
1.1.2.5. "Web Server Settings"
1.1.2.5.1. "App URL:" "https://localhost"
1.1.2.5.2. (checked)"Enable Anonymous Authentication"
2. In "IIS Local" manager "Add Website" with name "AspNetCoreMvcMovie".
2.1. Set "Physical path" with the project(NOT the solution) folder(in our case "D:\ASP-NET-Core\ASP-NET-Core-Projects\MvcMovie\MvcMovie").
2.2. Binding "Type" : "https".
2.3. "SSL certificate" : "IIS Express Development Certificate".
2.4. Click "OK".
2.5. Into "Application Pools" find by name "AspNetCoreMvcMovie" pool.
2.5.1. Into "Edit Application Pool" set ".NET CLR version" to "No Managed Code".
2.5.2. Click "OK".
3. Set VS 2017 elevated permissions.
3.1. If we have massage like that: "Microsoft Visual Studio": "This task requires the application to have elevated permissions", follow troubleshooting "(Method 2) Troubleshoot Compatibility" in next link: https://social.technet.microsoft.com/wiki/contents/articles/46441.visual-studio-2017-this-task-requires-the-application-to-have-elevated-permissions.aspx
3.2 After accomplishment of this method(Method 2), VS-2017 will start.
3.3. Run(in "Debug" mode) "MvcMovie" application with IIS-profile(which is set to run on IIS Local... !!! NOT the IIS Express !!!). In our case profile is set with name of the current application("MvcMovie") in "Step 1.".
3.4. Wait application to run in browser.
3.5. Close application(close web-browser).
3.6. Go to compatibility-troubleshooting-window and click "Next".
3.6.1. Then click on "-> Yes, save these settings for this program".
3.6.2. After "Resolving issues" finishes "Saving settings", we have to view window "Troubleshooting has completed". In the window "Troubleshooting has completed", have to view : "Issues found" -> "Incompatible Program" -> "Fixed". Then click on "-> Close the troubleshooter".
4. From VS-2017, Run(in "Debug" mode) again "MvcMovie" application with IIS-profile(in our case with name "MvcMovie").
The benefit is you can actually use the website outside using an actual hostname. Imagine having an android app trying to connect to localhost to debug an asp.net core web api service. a pain to setup unless you can actually use an actual physical ip address and connect to something running on iis. Just like BEFORE. Everything can be done but it doesn't mean if it's new it's automatically more practical. And not having the old debug iis option is a step backwards in terms of productivity.
Is this really necessary? ASP.NET Core applications run as an external process to IIS (using dotnet.exe) so there's really nothing gained by debugging through IIS. The backend application gets requests over plain HTTP.
For more info how the actual IIS hosting works with ASP.NET Core you might want to check out this blog post: http://weblog.west-wind.com/posts/2016/Jun/06/Publishing-and-Running-ASPNET-Core-Applications-with-IIS
Visual Studio currently doesn't support debugging under full IIS and from what I've heard this is not something that is planned either. Microsoft does support running with IIS Express and you can set up a certificate for IIS Express.
In the ASP.NET Core project, in the Debug Project options there's an Enable SSL option that you can enable. IIS Express will create a local certificate and let you debug your application using SSL.
The benefit with this approach is that it just works by pressing F5 - no manual attachment required.
I tried all the above suggestions, but nothing worked until I put all the missing elements together.
The essential parts of debugging in IIS are:
.NET Core 2.2 is needed to run your site WITHIN the IIS process.
Here's more detail: http://intrinsicinnovation.com/Articles/2019/01/08/debugging-asp-net-core-applications-within-iis/
Just went through the history and stumbled upon this one. In case anyone every comes to this question...the solution for me turned out to be quite simple. If you're using authentication on your .net core app simply make sure it's using basic auth using HTTP(for the debug part). Then in IIS simply use Url Rewrite to setup a reverse proxy to your http://localhost:someport .net core instance. That's it. Problem solved. Perhaps url rewrite will support https soon and in that case the auth basic using HTTP can be used for debugging purposes as well. Which would be great. But so far this setup solved all my problems.
I was looking for a solution that would allow me to debug a .NET core sub-app, while running on a website that hosts Classic ASP code.
Looooooka's reverse proxy solution worked for me, but it took some work to figure it out.
1.) Add this line to Startup.cs.
app.UsePathBase("/core"); // core is the name of my subdirectory
Make sure you put it BEFORE the line that says "app.UseStaticFiles();"
2.) Install "URL Rewrite v2" and "Application Request Routing"
3.) Add a folder to the IIS website (/core) and create a web.config file inside the folder like this:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="IISExpressReverseProxy" stopProcessing="true">
<match url="(.*)" />
<conditions>
</conditions>
<action type="Rewrite" url="http://localhost:1306/core/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
4.) Open the project properties in visual studio, and go to the debug tab. Change the "Launch browser" url to your IIS url.
I had the same issue for an ASP.NET Core 2.2 Web API project that I wanted to run against IIS.
"iisSettings": {
"windowsAuthentication": true,
"anonymousAuthentication": true,
"iis": {
"applicationUrl": "http://localhost/AspNetCore22Starter",
"sslPort": 443
},
Configure https binding. Also it is recommended to define a specific application pool for the web application in order to make attach process easier to find
Attach to process (Ctrl-Alt-P) + find w3wp.exe process + pick the one that has User Name = IIS APPPOOL\: