user1147862
user1147862

Reputation: 4226

How to attach debugger for ASP.NET Core web site running in IIS targeting net47?

I just converted a large legacy site to Net Core. Because of some old code, I have to target net47 instead of netcoreapp2.0 / netstandard2.0.

Problem is that when I run the site in IIS, it starts up correctly, but then I cannot attach the debugger. The process list (Debug | Attach to process) does not show the dotnet.exe process at all.

To investigate this:

After hitting the site, I was able to attach to the dotnet.exe process ok. Here is the .csproj file:

<Project Sdk="Microsoft.NET.Sdk.Web">
  
  <!-- dotnet.exe shows up in process list in Visual Studio 2017 -->
  
  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.3" />
  </ItemGroup>

  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.1" />
  </ItemGroup>
</Project>

I then retargeted it to net47 because that is what my site uses.

I could load the site ok and navigate around. However, dotnet.exe no longer appeared in the process list.

<Project Sdk="Microsoft.NET.Sdk.Web">
  
  <!-- dotnet.exe does NOT show up in process list in Visual Studio 2017 -->
  
  <PropertyGroup>
    <TargetFramework>net47</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore" Version="2.0.*" />
    <PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.0.*" />
    <PackageReference Include="Microsoft.Extensions.Configuration" Version="2.0.*" />
    <PackageReference Include="Microsoft.Extensions.Logging" Version="2.0.*" />
    <PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.0.*" />
    <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.0.*" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.*" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.*" />
    <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.*" />
    <PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.0.*" />
  </ItemGroup>

  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.1" />
  </ItemGroup>
</Project>

Is there any way I can debug a site running in IIS that targets the Net Framework?

Upvotes: 0

Views: 1479

Answers (2)

AperioOculus
AperioOculus

Reputation: 6821

It’s my experience that you must attach to the process name that matches your web application’s executable; the default value is the project name.

Upvotes: 1

SeanKilleen
SeanKilleen

Reputation: 8977

Does w3wp.exe appear? If so, see if selecting that for debugging works. If it’s targeting 47 and running in IIS, it may be using IIS’s w3wp process.

This is a guess given what I saw; not in a position to verify at the moment. Let me know if it works!

Upvotes: 0

Related Questions