How do you debug ASP.NET applications under IIS7 on Vista?
Asked Answered
M

4

4

There is a post on IIS.net titled "Using Visual Studio 2008 with IIS 7.0", but I don't quite believe that's what people do. (Among other gems, it suggests publishing your web app after every change.)

If you debug your ASP.NET applications in IIS7 instead of Cassini, I would love to hear your methods, tips, and tricks.

Edit: I'm referring specifically to local debugging.

Mopey answered 27/4, 2009 at 23:10 Comment(2)
Are you referring to local or remote debugging?Depew
I got so sick of Cassini bugs I create the site in IIS then open through visual studio and debug with F5, since then I have been a happier person.Bankston
B
2

I simply attach Visual Studio to the IIS worker process, if you have multiple app pools then you can run "issapp" to get the appropriate PID.

I never debug by clicking "Start Debugging".

This has a nice advantage of working on remote servers as well, if you have installed msvcmon.

Braden answered 27/4, 2009 at 23:19 Comment(1)
I've been doing this for the last 2 months, and it's definitely a huge improvement over F5.Mopey
R
4

I believe I pointed you toward that guide, but as I look closer at it I think that's a little more elaborate than what I do. I have done the following:

  1. Create a web site in IIS for your project.

  2. Add a custom host header to that site, for example http://mysite:*/ or http://mysite:80/

  3. Open the hosts file located at C:\Windows\system32\drivers\etc in notepad (Run As Admin if you're on Vista) and add the following line:

    mysite        127.0.0.1
    

    If you have more than one host header on your website in IIS, you need to have each one represented in the hosts file.

Now, when you press F5 in Visual Studio, the site will open with the url http://mysite and you'll be able to debug, set breakpoints etc as usual, except with no Cassini related problems... ;)

Edit: For clarification, I just want to point out that I have never had to attach any process to VS, as far as I know. At the very least I do not have to do it every time.

Riverhead answered 27/4, 2009 at 23:43 Comment(2)
So if your code is in some folder like c:\code\trunk\mywebsite, you set that path to be the root directory for the web site?Mopey
Yes. In IIS, you can choose the root path for your site as you wish, so you set the path to wherever you store your ASP.Net Web Project files.Riverhead
B
2

I simply attach Visual Studio to the IIS worker process, if you have multiple app pools then you can run "issapp" to get the appropriate PID.

I never debug by clicking "Start Debugging".

This has a nice advantage of working on remote servers as well, if you have installed msvcmon.

Braden answered 27/4, 2009 at 23:19 Comment(1)
I've been doing this for the last 2 months, and it's definitely a huge improvement over F5.Mopey
S
1

Well, setting up IIS 7 for debugging isn't terribly tricky, but what I prefer to do to save time (and if I'm uninterested in debugging from a cold start) is to launch the Web Application/Web Site in a web browser first - let ASP.net precompile etc.

Then I'll attach to the IIS process using Visual Studio. Once attached I can go about setting breakpoints and debugging, I find this is a faster way to get going.

Speck answered 27/4, 2009 at 23:16 Comment(0)
H
1

I launch Visual Studio as an Administrator, then Debug > Attach to Process > w3wp.exe.

Happy answered 27/4, 2009 at 23:37 Comment(1)
Thanks, this is good for when you don't have the entire website open in VSMesne

© 2022 - 2024 — McMap. All rights reserved.