调试本地IIS Web服务器上托管的ASP.NET MVC3应用程序

时间:2021-09-17 04:09:41

I've managed to use the local IIS Webserver to host my MVC3 application, and I can debug it and everything, from the machine that is hosting it. - however, when I send a request from another machine (my Mac, which is running my Windows in a Parallels VM), I get the expected result, but the debugger wont stop at my breakpoints!

我已经设法使用本地IIS Web服务器来托管我的MVC3应用程序,我可以从托管它的机器调试它和所有东西。 - 但是,当我从另一台机器(我的Mac,在Parallels VM中运行我的Windows)发送请求时,我得到了预期的结果,但是调试器不会停在我的断点处!

I tried adding a Debugger.Break(); to my action, and that crashes the w3wp.exe ..

我尝试添加Debugger.Break();我的行动,并崩溃w3wp.exe ..

To, so summarize: Local requests are working, and can be debugged. External requests are working, but they cannot be debugged.

To,总结一下:本地请求正在运行,可以调试。外部请求正在运行,但无法进行调试。

In my project's properties, I set the Use Local IIS Webserver, Use IIS Express is unchecked.

在我的项目属性中,我设置了使用本地IIS Web服务器,未选中使用IIS Express。

I'm using Visual Studio 2012 Professional. The project is Azure SDK-based, and the attached process is WaIISHost.exe.

我正在使用Visual Studio 2012 Professional。该项目是基于Azure SDK的,附加的进程是WaIISHost.exe。

4 个解决方案

#1


10  

The issue was that since I had set up my IIS server to serve on port 83, while locally I would access on port 81, the debugger would not monitor those requests.

问题是,由于我已将IIS服务器设置为在端口83上提供服务,而本地我将在端口81*问,因此调试器不会监视这些请求。

To solve this (or, generally, to debug remotely on the Cassini Web Server), download a tool called rinetd, which is a very simple traffic redirector daemon, and create a config.cfg in the folder where you extracted it to. The format is <source ip> <source port> <dest. ip> <dest port>. So, on my Mac, I go to this address in Safari: 192.168.1.23:8080/Controller/Action , and that is then redirected to localhost:81/Controller/Action , as if it was a local request! Here is the example config.cfg:

要解决此问题(或者,通常在Cassini Web服务器上进行远程调试),请下载名为rinetd的工具,该工具是一个非常简单的流量重定向器守护程序,并在您将其解压缩到的文件夹中创建config.cfg。格式为 。所以,在我的Mac上,我转到Safari中的这个地址:192.168.1.23:8080 / Controller / Action,然后将其重定向到localhost:81 / Controller / Action,就像它是本地请求一样!这是config.cfg的示例: 。>

192.168.1.23 8080 127.0.0.1 81

Alternatively, you can use your PC name, to avoid having to assign a static IP or change the config when DHCP gives you a new address:

或者,您可以使用您的PC名称,以避免在DHCP为您提供新地址时分配静态IP或更改配置:

Jeff-PC 8080 127.0.0.1 81

Then, open a command prompt, and cd to your rinetd folder, and run rinetd.exe -c config.cfg.

然后,打开命令提示符,并cd到您的rinetd文件夹,然后运行rinetd.exe -c config.cfg。

Works like a charm.

奇迹般有效。

#2


7  

I can see that the remote requests are served by IIS, but the local ones are served via "Cassini" server or the server of visual studio.

我可以看到远程请求由IIS提供,但是本地的请求是通过“Cassini”服务器或visual studio的服务器提供的。

Make sure that you are using IIS to debug your code, You can attache visual studio to w3wp.exe to debug via IIS. and you should start visual studio as Administrator.

确保您使用IIS来调试代码,您可以将visual studio附加到w3wp.exe以通过IIS进行调试。你应该以管理员身份启动visual studio。

To attache Visual studio to w3wp.exe (IIS process): From visual studio, from the debug menu select "Attach to process..." :

将Visual Studio附加到w3wp.exe(IIS进程):从visual studio,从调试菜单中选择“Attach to process ...”:

  • Check "Show processes from all users".

    选中“显示所有用户的进程”。

  • Check "Show processes in all sessions".

    选中“在所有会话中显示进程”。

  • Choose "Managed (v....) code" from (Attach to.) by pressing select button.

    按选择按钮从(附加到。)中选择“托管(v ....)代码”。

  • Press "Refresh" button

    按“刷新”按钮

w3wp.exe should be shown!

应该显示w3wp.exe!

调试本地IIS Web服务器上托管的ASP.NET MVC3应用程序

#3


2  

When you start Visual Studio, start it as Administrator (right click and 'Run as administrator'), then load your project's solution.

当您启动Visual Studio时,以管理员身份启动它(右键单击并以“以管理员身份运行”),然后加载项目的解决方案。

Then from the debug menu select "Attach to process..." and ensure that the "Show processes from all users" and "show processes in all sessions" checkboxes are checked, within the Available Processes panel you should be able to scroll through and locate a process that relates to the IIS app pool that you are trying to debug (usually called w3wp.exe).

然后从调试菜单中选择“附加到进程...”并确保选中“显示所有用户的进程”和“在所有会话中显示进程”复选框,在“可用进程”面板中,您应该能够滚动并且找到与您尝试调试的IIS应用程序池相关的进程(通常称为w3wp.exe)。

Attach to this process and refresh the page in your browser, this should allow you to debug.

附加到此过程并在浏览器中刷新页面,这应该允许您进行调试。

Many Thanks.

非常感谢。

Benjamin

本杰明

#4


2  

You are probably attaching the wrong process.

您可能附加了错误的过程。

Try to do the below to confirm you are debugging the wrong process.

尝试执行以下操作以确认您正在调试错误的进程。

  • From your local machine start the web application in debug mode (press F5).
  • 从本地计算机以调试模式启动Web应用程序(按F5)。
  • Go on Debug -- > Attach process
  • 继续调试 - >附加过程

Now if you scroll down you should see which is the process VS has attached to debug your application (It should appear in a different color -light gray). If the process is not the w3wp.exe it means you are not using IIS for hosting your application and you are probably debugging the wrong process when you make a request from another machine

现在,如果向下滚动,您应该看到VS已经附加到调试应用程序的过程(它应该以不同的颜色显示 - 浅灰色)。如果进程不是w3wp.exe,则表示您没有使用IIS来托管应用程序,并且当您从另一台机器发出请求时,您可能正在调试错误的进程

#1


10  

The issue was that since I had set up my IIS server to serve on port 83, while locally I would access on port 81, the debugger would not monitor those requests.

问题是,由于我已将IIS服务器设置为在端口83上提供服务,而本地我将在端口81*问,因此调试器不会监视这些请求。

To solve this (or, generally, to debug remotely on the Cassini Web Server), download a tool called rinetd, which is a very simple traffic redirector daemon, and create a config.cfg in the folder where you extracted it to. The format is <source ip> <source port> <dest. ip> <dest port>. So, on my Mac, I go to this address in Safari: 192.168.1.23:8080/Controller/Action , and that is then redirected to localhost:81/Controller/Action , as if it was a local request! Here is the example config.cfg:

要解决此问题(或者,通常在Cassini Web服务器上进行远程调试),请下载名为rinetd的工具,该工具是一个非常简单的流量重定向器守护程序,并在您将其解压缩到的文件夹中创建config.cfg。格式为 。所以,在我的Mac上,我转到Safari中的这个地址:192.168.1.23:8080 / Controller / Action,然后将其重定向到localhost:81 / Controller / Action,就像它是本地请求一样!这是config.cfg的示例: 。>

192.168.1.23 8080 127.0.0.1 81

Alternatively, you can use your PC name, to avoid having to assign a static IP or change the config when DHCP gives you a new address:

或者,您可以使用您的PC名称,以避免在DHCP为您提供新地址时分配静态IP或更改配置:

Jeff-PC 8080 127.0.0.1 81

Then, open a command prompt, and cd to your rinetd folder, and run rinetd.exe -c config.cfg.

然后,打开命令提示符,并cd到您的rinetd文件夹,然后运行rinetd.exe -c config.cfg。

Works like a charm.

奇迹般有效。

#2


7  

I can see that the remote requests are served by IIS, but the local ones are served via "Cassini" server or the server of visual studio.

我可以看到远程请求由IIS提供,但是本地的请求是通过“Cassini”服务器或visual studio的服务器提供的。

Make sure that you are using IIS to debug your code, You can attache visual studio to w3wp.exe to debug via IIS. and you should start visual studio as Administrator.

确保您使用IIS来调试代码,您可以将visual studio附加到w3wp.exe以通过IIS进行调试。你应该以管理员身份启动visual studio。

To attache Visual studio to w3wp.exe (IIS process): From visual studio, from the debug menu select "Attach to process..." :

将Visual Studio附加到w3wp.exe(IIS进程):从visual studio,从调试菜单中选择“Attach to process ...”:

  • Check "Show processes from all users".

    选中“显示所有用户的进程”。

  • Check "Show processes in all sessions".

    选中“在所有会话中显示进程”。

  • Choose "Managed (v....) code" from (Attach to.) by pressing select button.

    按选择按钮从(附加到。)中选择“托管(v ....)代码”。

  • Press "Refresh" button

    按“刷新”按钮

w3wp.exe should be shown!

应该显示w3wp.exe!

调试本地IIS Web服务器上托管的ASP.NET MVC3应用程序

#3


2  

When you start Visual Studio, start it as Administrator (right click and 'Run as administrator'), then load your project's solution.

当您启动Visual Studio时,以管理员身份启动它(右键单击并以“以管理员身份运行”),然后加载项目的解决方案。

Then from the debug menu select "Attach to process..." and ensure that the "Show processes from all users" and "show processes in all sessions" checkboxes are checked, within the Available Processes panel you should be able to scroll through and locate a process that relates to the IIS app pool that you are trying to debug (usually called w3wp.exe).

然后从调试菜单中选择“附加到进程...”并确保选中“显示所有用户的进程”和“在所有会话中显示进程”复选框,在“可用进程”面板中,您应该能够滚动并且找到与您尝试调试的IIS应用程序池相关的进程(通常称为w3wp.exe)。

Attach to this process and refresh the page in your browser, this should allow you to debug.

附加到此过程并在浏览器中刷新页面,这应该允许您进行调试。

Many Thanks.

非常感谢。

Benjamin

本杰明

#4


2  

You are probably attaching the wrong process.

您可能附加了错误的过程。

Try to do the below to confirm you are debugging the wrong process.

尝试执行以下操作以确认您正在调试错误的进程。

  • From your local machine start the web application in debug mode (press F5).
  • 从本地计算机以调试模式启动Web应用程序(按F5)。
  • Go on Debug -- > Attach process
  • 继续调试 - >附加过程

Now if you scroll down you should see which is the process VS has attached to debug your application (It should appear in a different color -light gray). If the process is not the w3wp.exe it means you are not using IIS for hosting your application and you are probably debugging the wrong process when you make a request from another machine

现在,如果向下滚动,您应该看到VS已经附加到调试应用程序的过程(它应该以不同的颜色显示 - 浅灰色)。如果进程不是w3wp.exe,则表示您没有使用IIS来托管应用程序,并且当您从另一台机器发出请求时,您可能正在调试错误的进程