I'm not able to debug asp .net core web applications under virtual directories in IIS Express

烈酒焚心 提交于 2019-12-25 01:19:33

问题


Hope, I will get help here, because, if seriosuly, I spent few days on this problem, and I really have no idea, what I missed, but I am not able to debug web apps on asp .net core under virtual directories. I did the same on my previous project on asp. net framework (not .net core), and it worked without any issues. The main idea is to have separate web applications for some paths in url (child sites): site.com - one root web application, site.com/broker/ - another web app, site.com/services - another web app and etc. I even checked again to compare, how it works in .net framework 4.7. I created two web applications under the one solution, created virtual directories in VS (there is a button "Create virtual directory" in "Web" tab in project properties), but as I understand, all, that this button does is addding virtual directories in "applicationhost.config" for IIS Express. Ok, you can set a breakpoint in any action in controller in services web app, launch root web app, go to site.com/services/controller/action and breakpoint will be hit.

But it doesn't work in case of asp .net core 2.2. There is no button "Create virtual directory" in VS, but I added virtual directories in "applicationhost.config" manually.

    <sites>
      <site name="WebSite1" id="1" serverAutoStart="true">
        <application path="/">
          <virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\WebSite1" />
        </application>
        <bindings>
          <binding protocol="http" bindingInformation=":8080:localhost" />
        </bindings>
      </site>
      <site name="Main.Web" id="2">
        <application path="/" applicationPool="Clr4IntegratedAppPool">
          <virtualDirectory path="/" physicalPath="C:\projects\treasury\main\Main.Web" />
        </application>
        <application path="/broker" applicationPool="Clr4IntegratedAppPool">
          <virtualDirectory path="/" physicalPath="C:\projects\treasury\broker\Broker.Web" />
        </application>
        <application path="/services" applicationPool="Clr4IntegratedAppPool">
          <virtualDirectory path="/" physicalPath="C:\projects\treasury\services\Services.Web" />
        </application>
        <application path="/dictionary" applicationPool="Clr4IntegratedAppPool">
          <virtualDirectory path="/" physicalPath="C:\projects\treasury\dictionary\Dictionary.Web" />
        </application>
        <bindings>
          <binding protocol="http" bindingInformation="*:56164:localhost" />
        </bindings>
      </site>
      <siteDefaults>
        <!-- To enable logging, please change the below attribute "enabled" to "true" -->
        <logFile logFormat="W3C" directory="%AppData%\Microsoft\IISExpressLogs" enabled="false" />
        <traceFailedRequestsLogging directory="%AppData%\Microsoft" enabled="false" maxLogFileSizeKB="1024" />
      </siteDefaults>
      <applicationDefaults applicationPool="Clr4IntegratedAppPool" />
      <virtualDirectoryDefaults allowSubDirConfig="true" />
    </sites>

As I understand, availability of web.config in root web app is not necessary, but all child web apps have such web.config with the corresponding paths to dll (it is just an example of "services" web app):

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <!--
    Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380
  -->
  <system.webServer>
    <handlers>
      <remove name="aspNetCore"/>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="dotnet" arguments=".\bin\Debug\netcoreapp2.2\Services.Web.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
  </system.webServer>
</configuration>

IIS Express understands this configuration and virtual directories work as I expected:

IIS Express

BUT!

I am not able to debug child applications. Visual studio doesn't attach debugger for them, there are no these dll in "Modules" window, and it looks like I got deployed application exactly how it's going to be deployed in IIS on the server. But not for dev environement. Visual studio launches root web app, that just uses another web apps as external compiled dll (of course there are pdb files in every bin folder), and doesn't debug them.

If child web application has unique controller name, then VS tells, that there are no symbols loaded:

Breakpoint with unique controller name

If child web application has nonunique controller name (for example, there is HomeController in root app and there is HomeController in child app), then I get this message:

Breakpoint with nonunique controller name

I'm wondering, because the same configuration works without any problems in asp .net framework web application. I know, that IIS Express for asp .net framework is not the same IIS Express, that works for asp .net core, because there is a kestrel, but I'm not sure, that this is the reason, because virtual directories works, routing works, and the problem is only with debugger. Also I'm wondering, I didn't find any helpful information here or other sites, and it looks like nobody has such problem.

Guys, please, give me any thoughts or any help, what I missed?

Thanks!

来源:https://stackoverflow.com/questions/58163440/im-not-able-to-debug-asp-net-core-web-applications-under-virtual-directories-i

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!