I have an ASP.NET website and when I press F5 it automatically attaches to the ASP.NET Development Server, how do I attach to IIS worker process instead when I press F5?
我有一个ASP。当我按F5时,它会自动连接到ASP。NET开发服务器,当我按F5时,如何将其附加到IIS工作进程?
5 个解决方案
#1
49
open project properties, go to the web tab and choose the option for IIS.
打开项目属性,转到web选项卡,选择IIS的选项。
That actually starts an instance of the app in IIS and attaches the debugger. If you only wanted to attach to an existing IIS instance, choose attach to process from the debug menu.
这实际上启动了IIS中的一个应用程序实例,并附加调试器。如果您只想附加到一个现有的IIS实例,请从debug菜单中选择attach to process。
#2
91
Debug->Attach To Process...
调试- >附加过程……
Select the aspnet_wp.exe process from the list.
选择aspnet_wp。从列表中执行进程。
If you're running IIS > version 5 the process will be w3wp.exe, and there will be one for every app pool (so if you don't know which app pool you're hitting, you'll need to attach to all of them).
如果您正在运行IIS >版本5,那么进程将是w3wp。exe,每个应用程序池都有一个(所以如果你不知道你点击的是哪个应用程序池,你需要连接到所有的应用程序池)。
#3
11
Debug -> Attach to Process from the VS menu.
调试->附加到进程从VS菜单。
In order to know to which w3wp.exe process to attach you can use the following command on a 2008 server
为了知道w3wp。要附加exe进程,可以在2008服务器上使用以下命令
c:\%systemroot%\system32\inetsrv\appcmd list wp
While on windows 2003 it is
在windows 2003上是这样的
c:\%systemroot%\system32\cscript iisapp.vbs
For more info see IIS Application pool PID.
有关更多信息,请参见IIS应用程序池PID。
However if you have access to the task manager (taskmgr.exe) you can see there directly the name of the process along with the process ID, and in most cases the "user name" column of the process will be the same as the application pool name, (of course you have to set these columns to be visible in task manager in order to view the information).
但是如果你有进入任务管理器(任务管理器)可以看到直接进程的进程ID的名称,而且在大多数情况下进程的“用户名”列将应用程序池名称一样,(当然,你必须将这些列设置为可见在任务管理器查看信息)。
But note that all of the methods will display only the processes that are currently running, which means that if your particular process has shut down due to idle time you have first to use the site in order to bring the process up in the list.
但是请注意,所有的方法将只显示当前正在运行的进程,这意味着如果您的特定进程由于空闲时间而关闭,您必须首先使用这个站点,以便将进程放在列表中。
Also if the application is a "Web Garden" (which has more than one w3wp.exe) then even after attaching to the correct process there is still no guarantee that the breakpoints will be hit, since traffic to the site might be directed to another process.
此外,如果应用程序是一个“Web花园”(它有一个以上的w3wp.exe),那么即使在连接到正确的进程之后,仍然不能保证会命中断点,因为到站点的流量可能会指向另一个进程。
Also note that if you attach to an application that runs in release mode, it will now instead run in debug mode, which means for example that there will be no timeout limitations (which might be a bit of a problem if you are actually trying to troubleshoot a timeout error).
也请注意,如果您将一个应用程序,该应用程序在发布模式下运行时,它将现在在调试模式下运行,这意味着,例如,不会有超时限制(可能有点问题,如果你试图解决一个超时错误)。
If you want to attach to a remote process here is the best practice:
如果您想附加到远程进程,这里是最佳实践:
- Make sure that the firewall is not blocking by opening the relevant ports or completely disabling it (just remember to turn it on again when done).
- 通过打开相关端口或完全禁用防火墙来确保防火墙没有阻塞(只要记住在打开时再次打开它)。
- You should have a windows domain account with administrative privileges on the remote machine or have an account - with the same username and password as the local machine which is running VS - on the remote machine.
- 您应该有一个在远程计算机上具有管理权限的windows域帐户,或者有一个与正在远程计算机上运行VS的本地计算机具有相同的用户名和密码的帐户。
- On the machine that has VS installed navigate to (Visual Studio Install path)\Microsoft Visual Studio (current version number)\Common7\IDE\Remote Debugger(Remote Machine Version), and copy and paste this folder to the remote machine or share this folder so that it is accessible from the remote machine.
- 在安装了VS的机器上导航到(Visual Studio安装路径)\Microsoft Visual Studio(当前版本号)\Common7\IDE Remote Debugger(Remote Debugger)调试器(Remote machine version),并将该文件夹复制粘贴到远程机器上,或者共享此文件夹,以便从远程机器*问该文件夹。
- On the remote machine log in as the same user as the local machine (see step 2) from there navigate to the copied or shared folder of step 3, and right click on "msvsmon.exe" and from the context menu select "Run As Administrator".
- 在远程机器上以与本地机器相同的用户登录(参见第2步),导航到第3步的复制或共享文件夹,然后右键单击“msvsmon”。exe和从上下文菜单中选择“作为管理员运行”。
- The Remote Monitor should start up and claim that it started a server usually by the name of (user)@(remote machine) or any other name.
- 远程监视器应该启动并声明它通常以(用户)@(远程机器)或任何其他名称启动服务器。
- In VS select Debug -> Attach To Process from the menu, leave the transport on "Default" and for the "Qualifier Name" enter the name from step 5.
If everything goes correctly this will bring up the list of processes on the remote machine.
- 在VS中选择Debug ->从菜单中附加到进程,在“Default”中保留传输,而“Qualifier名称”则从步骤5中输入名称。如果一切正常,这将显示远程机器上的进程列表。
Of course there is a lot more in this subject, and for debugging native code the process might be even simpler, but the steps I have listed here should work in every case.
当然,本主题中还有很多内容,对于调试本机代码,这个过程可能更简单,但是我在这里列出的步骤应该适用于所有情况。
For farther information you can take a look on http://www.codeproject.com/KB/aspnet/IISRemoteDebugging.aspx or on the MSDN, as well as many posts on this site.
Hope this will help.
要了解更多信息,您可以查看http://www.codeproject.com/KB/aspnet/IISRemoteDebugging.aspx或MSDN,以及这个站点上的许多文章。希望这将帮助。
#4
7
Or you can use one of the Attach to IIS plugins to Visual Studio.
或者您可以使用一个附加到Visual Studio的IIS插件。
My preferred extension is VSCommands (for VS 2010 - 2012 or 2013, but not 2015 yet) or ReAttach (works in 2017).
我比较喜欢的扩展是VSCommands(2010 - 2012或2013年,但还没有2015年)或ReAttach(2017年生效)。
#5
6
go to the properties of the web application. Select the "Start Options" section, and change from "USe default web server" to "use custom server". Enter "http://localhost" in the base url.
转到web应用程序的属性。选择“开始选项”部分,从“使用默认web服务器”更改为“使用自定义服务器”。在基本url中输入“http://localhost”。
(assumes VS 2008)
(假定VS 2008)
#1
49
open project properties, go to the web tab and choose the option for IIS.
打开项目属性,转到web选项卡,选择IIS的选项。
That actually starts an instance of the app in IIS and attaches the debugger. If you only wanted to attach to an existing IIS instance, choose attach to process from the debug menu.
这实际上启动了IIS中的一个应用程序实例,并附加调试器。如果您只想附加到一个现有的IIS实例,请从debug菜单中选择attach to process。
#2
91
Debug->Attach To Process...
调试- >附加过程……
Select the aspnet_wp.exe process from the list.
选择aspnet_wp。从列表中执行进程。
If you're running IIS > version 5 the process will be w3wp.exe, and there will be one for every app pool (so if you don't know which app pool you're hitting, you'll need to attach to all of them).
如果您正在运行IIS >版本5,那么进程将是w3wp。exe,每个应用程序池都有一个(所以如果你不知道你点击的是哪个应用程序池,你需要连接到所有的应用程序池)。
#3
11
Debug -> Attach to Process from the VS menu.
调试->附加到进程从VS菜单。
In order to know to which w3wp.exe process to attach you can use the following command on a 2008 server
为了知道w3wp。要附加exe进程,可以在2008服务器上使用以下命令
c:\%systemroot%\system32\inetsrv\appcmd list wp
While on windows 2003 it is
在windows 2003上是这样的
c:\%systemroot%\system32\cscript iisapp.vbs
For more info see IIS Application pool PID.
有关更多信息,请参见IIS应用程序池PID。
However if you have access to the task manager (taskmgr.exe) you can see there directly the name of the process along with the process ID, and in most cases the "user name" column of the process will be the same as the application pool name, (of course you have to set these columns to be visible in task manager in order to view the information).
但是如果你有进入任务管理器(任务管理器)可以看到直接进程的进程ID的名称,而且在大多数情况下进程的“用户名”列将应用程序池名称一样,(当然,你必须将这些列设置为可见在任务管理器查看信息)。
But note that all of the methods will display only the processes that are currently running, which means that if your particular process has shut down due to idle time you have first to use the site in order to bring the process up in the list.
但是请注意,所有的方法将只显示当前正在运行的进程,这意味着如果您的特定进程由于空闲时间而关闭,您必须首先使用这个站点,以便将进程放在列表中。
Also if the application is a "Web Garden" (which has more than one w3wp.exe) then even after attaching to the correct process there is still no guarantee that the breakpoints will be hit, since traffic to the site might be directed to another process.
此外,如果应用程序是一个“Web花园”(它有一个以上的w3wp.exe),那么即使在连接到正确的进程之后,仍然不能保证会命中断点,因为到站点的流量可能会指向另一个进程。
Also note that if you attach to an application that runs in release mode, it will now instead run in debug mode, which means for example that there will be no timeout limitations (which might be a bit of a problem if you are actually trying to troubleshoot a timeout error).
也请注意,如果您将一个应用程序,该应用程序在发布模式下运行时,它将现在在调试模式下运行,这意味着,例如,不会有超时限制(可能有点问题,如果你试图解决一个超时错误)。
If you want to attach to a remote process here is the best practice:
如果您想附加到远程进程,这里是最佳实践:
- Make sure that the firewall is not blocking by opening the relevant ports or completely disabling it (just remember to turn it on again when done).
- 通过打开相关端口或完全禁用防火墙来确保防火墙没有阻塞(只要记住在打开时再次打开它)。
- You should have a windows domain account with administrative privileges on the remote machine or have an account - with the same username and password as the local machine which is running VS - on the remote machine.
- 您应该有一个在远程计算机上具有管理权限的windows域帐户,或者有一个与正在远程计算机上运行VS的本地计算机具有相同的用户名和密码的帐户。
- On the machine that has VS installed navigate to (Visual Studio Install path)\Microsoft Visual Studio (current version number)\Common7\IDE\Remote Debugger(Remote Machine Version), and copy and paste this folder to the remote machine or share this folder so that it is accessible from the remote machine.
- 在安装了VS的机器上导航到(Visual Studio安装路径)\Microsoft Visual Studio(当前版本号)\Common7\IDE Remote Debugger(Remote Debugger)调试器(Remote machine version),并将该文件夹复制粘贴到远程机器上,或者共享此文件夹,以便从远程机器*问该文件夹。
- On the remote machine log in as the same user as the local machine (see step 2) from there navigate to the copied or shared folder of step 3, and right click on "msvsmon.exe" and from the context menu select "Run As Administrator".
- 在远程机器上以与本地机器相同的用户登录(参见第2步),导航到第3步的复制或共享文件夹,然后右键单击“msvsmon”。exe和从上下文菜单中选择“作为管理员运行”。
- The Remote Monitor should start up and claim that it started a server usually by the name of (user)@(remote machine) or any other name.
- 远程监视器应该启动并声明它通常以(用户)@(远程机器)或任何其他名称启动服务器。
- In VS select Debug -> Attach To Process from the menu, leave the transport on "Default" and for the "Qualifier Name" enter the name from step 5.
If everything goes correctly this will bring up the list of processes on the remote machine.
- 在VS中选择Debug ->从菜单中附加到进程,在“Default”中保留传输,而“Qualifier名称”则从步骤5中输入名称。如果一切正常,这将显示远程机器上的进程列表。
Of course there is a lot more in this subject, and for debugging native code the process might be even simpler, but the steps I have listed here should work in every case.
当然,本主题中还有很多内容,对于调试本机代码,这个过程可能更简单,但是我在这里列出的步骤应该适用于所有情况。
For farther information you can take a look on http://www.codeproject.com/KB/aspnet/IISRemoteDebugging.aspx or on the MSDN, as well as many posts on this site.
Hope this will help.
要了解更多信息,您可以查看http://www.codeproject.com/KB/aspnet/IISRemoteDebugging.aspx或MSDN,以及这个站点上的许多文章。希望这将帮助。
#4
7
Or you can use one of the Attach to IIS plugins to Visual Studio.
或者您可以使用一个附加到Visual Studio的IIS插件。
My preferred extension is VSCommands (for VS 2010 - 2012 or 2013, but not 2015 yet) or ReAttach (works in 2017).
我比较喜欢的扩展是VSCommands(2010 - 2012或2013年,但还没有2015年)或ReAttach(2017年生效)。
#5
6
go to the properties of the web application. Select the "Start Options" section, and change from "USe default web server" to "use custom server". Enter "http://localhost" in the base url.
转到web应用程序的属性。选择“开始选项”部分,从“使用默认web服务器”更改为“使用自定义服务器”。在基本url中输入“http://localhost”。
(assumes VS 2008)
(假定VS 2008)