Reputation: 33118
The default ASP.NET web server that launches from within Visual Studio (Casini) is a little buggy on my development machine, so I like to publish to a local IIS instance on my dev machine and look at the web application there. However, I'm not automatically in "Debug Mode" when I launch the application this way.
I know that VS 2010 has an "Attach to Process" debug feature, but I'm not sure exactly how to use it. What do I need to do to be able to debug a local IIS ASP.NET web application from within Visual Studio? Specifically:
Background Information: I'm running Visual Studio 2010 on Windows XP SP3 with IIS 5.1 and .NET 4.0.
Additional Information:
I should add that I've tried attaching to aspnet_wp.exe, but when I go to a page that I know has a breakpoint in it, I get the following message when I hover over the "open circle" breakpoint:
The breakpoint will not currently be hit. No symbols have been loaded for this document.
Upvotes: 10
Views: 5307
Reputation: 2226
I know that you solve your problem, but maybe it will help others.
*step 2 and 3 can be replace with the keyboard shortcut Ctrl+Alt+P
*if there are more then one, you can select them all OR (for knowing the right one) open IIS and right click the website you want to debug > "manage application" > "advanced settings..." > look for the line "application pool", in the tab next to it, the name of the application pool that the website is using is written.
choose the w3wp process from the list
click on the button "attach"
in the project place a break-point in the code where you want to debug.
if you are seeing a break-point in red color but the inner color is white and when you hover it this message appears:
The breakpoint will not currently be hit. No symbols have been loaded for this document.
it means that the symbols not loaded = the right/updated dll's
was not loaded!
Build the project > go to the "bin" folder and copy the right dll
(projectName.dll) + also copy the (projectName.pdb), pdb
is like a map for this dll.
copy these 2 files into the website folder in the file system (there will be a dll
with the same name- replace it, and add the pdb
file also.
Then attach the process again like you did before- now the break-point should be whole red and when you load the website the break-point will hit.
Upvotes: 0
Reputation: 33118
I wasn't ever to get it work using F5 in Visual Studio, even when it was set up to deploy to the local IIS server. I'm not sure what exactly the problem was, but I eventually was able to get it to work in a much more "manual" fashion. A big part of getting this to work is to make sure you are generating debug symbols and deploying them to your web site. Here are the steps I took to eventually get it work:
IIS Web Site Name
/Virtual Directory
After you've done the above, you should be ready to deploy your application so that it can be debugged. Here are the steps I use to deploy and subsequently debug the application:
While this method works great, keep in mind that it's not just attached to your local development environment. If another user on a different computer were to access the web application, I believe the breakpoints will still fire as long as your are debugging the process.
Upvotes: 4
Reputation: 33867
Right click on your web project in VS, go to start options and choose Use Custom Server, pasting in the localhost address you have for your site in IIS.
Hit F5, will run in IIS.
Upvotes: 1
Reputation: 25692
I also develop my web apps on a local IIS. For local IIS debugging, F5 has always worked for me.
If you must use attach to process, for whatever reason, ensure that you are either attaching to a local process or that the remote debugger is running on the remote machine. The application must be spun up in advance, say, by requesting a page in a browser. Use iisapp
(IIS 5.1, 6.0) or appcmd list wp
(IIS 7+) to determine which process ID belongs to which application pool (only necessary if you have 2+ application pools, really), and then get rolling with Attach to Process.
Upvotes: 1
Reputation: 21905
I have never made any special settings, and the attach to process gadget works very well. Just attach to the aspnet_wp.exe process and there you go.
Upvotes: 0
Reputation: 33128
Al you need to do is use attach to process and target aspnet_wp.exe. It could possibly be w3wp.exe depending on flavor of OS. I used to have a macro for doing this but it stopped working after VS2008.
Upvotes: 5