无需在IIS上发布即可进行ASP.NET Core应用程序调试 [英] ASP.NET Core application debugging without publishing on IIS

查看:530
本文介绍了无需在IIS上发布即可进行ASP.NET Core应用程序调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以前使用过asp.net mvc4,在IIS中,我网站的物理路径会指向我的解决方案目录,并且每次更新代码时,我都重新构建解决方案,然后可以使用附加以处理"( w3wp)开始调试.

I used to use asp.net mvc4 and in IIS my website's physical path would point my solution directory, and every time I update my code, I just re-build my solution and then I can use "Attach to process" (w3wp) to start debugging.

在asp.net核心中,当我将网站发布到文件系统时,可以使用带有无托管代码的IIS运行我的网站.但是,当我将IIS网站指向我的网站解决方案代码时,它显示502错误.

In asp.net core, when I publish my website to file system, I can run my website using IIS with no-managed code. But when I point my IIS Website to my solution code of website, it shows 502 error.

推荐答案

简单答案:发布后,您将调用启动publish-iis工具的脚本(请参见project.json).

Simple answer: when you do publish, you call a script that launches the publish-iis tool (see script section in project.json).

在您的项目中,您有一个web.config文件,其内容如下:

In your project you have a web.config file with something like this:

<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" 
 stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/

如您所见,有占位符"%LAUNCHER_PATH%"%LAUNCHER_ARGS%参数.请记住这些.

As you see, there are placeholders "%LAUNCHER_PATH%" and %LAUNCHER_ARGS% parameters. Keep these in mind.

现在打开您的project.json文件,您将看到一个类似于以下内容的脚本"部分:

Now open your project.json file and you will see a "scripts" section looking something like this:

"scripts":
{  
    "postpublish":"dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"
}

它告诉dotnet在应用程序发布后运行publish-iis工具. 如何它有效:

It tells dotnet to run the publish-iis tool after the application is published. How it works:

publish-iis工具转到发布应用程序的文件夹(而不是项目文件夹),并检查它是否包含web.config文件.如果没有,它将创建一个.如果是的话,它将检查您拥有哪种类型的应用程序(即,它是针对完整CLR还是Core CLR,以及–对于Core CLR –是便携式应用程序还是独立应用程序),并将设置processPath和arguments属性的值删除%LAUNCHER_PATH%和%LAUNCHER_ARGS%占位符.

publish-iis tool goes to the folder where the application was published (not your project folder) and checks if it contains a web.config file. If it doesn’t, it will create one. If it does, it will check what kind of application you have (i.e. whether it is targeting full CLR or Core CLR and – for Core CLR – whether it is a portable or standalone application) and will set the values of the processPath and arguments attributes removing %LAUNCHER_PATH% and %LAUNCHER_ARGS% placeholders on the way.

这篇关于无需在IIS上发布即可进行ASP.NET Core应用程序调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆