How do you debug ASP.NET applications under IIS7 on Vista? - asp.net

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.

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:
Create a web site in IIS for your project.
Add a custom host header to that site, for example http://mysite:*/ or http://mysite:80/
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.

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.

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.

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

Related

Local Host redirected you too many times Issue with IIS

I am working on bringing a working web application onto a new computer running Visual Studio 2022 version 17.4.2 and .NET Framework 4.7.2. When running on local IIS (version 10.0) host there is a "local host redirected you too many times" issue. It suggests clearing cookies which has been done with no effect.
The same code works on other machines with no issues. Is there anything in IIS set up/configuration or that may be missing from Visual Studio or other installations? Thanks in advance.
So far we have tried debugging the code and including breakpoints for where the issue may be occurring, ensuring that the installations of windows feature and IIS management is the same as another where the program is working. Also created a .txt file that can be reached on local host and is in same location as the rest of the project.
Here are a few things you can try:
Try on another machine.
Try to remove as much rules as possible from web.config and keys and so on. Or if it's a single page you're having the error with try to remove as much code from it especially if there are redirect codes. And add breakpoints and debug.
Check the LOCAL application pool version if it's set same as the online .net framework version.

How does the view in browser option work in Visual Studio without IIS?

It seems like the View in Browser option doesn't really require IIS and it seems to process ASP pages fine. So how does it really work without a web server?
They used to have a developer web server (Cassini) which is dead long time back so is there some kind of built in capability in visual studio? Who processes the requests by asp pages if it doesn't require IIS?
I already have IIS installed so I am not sure if is servicing the pages but seems like it will work without IIS because I don't configure anything in IIS and new ASP.NET projects work out of the box as well View in Browser option for an asp page option which just directly executes that page.
Actually this is what occurs:
Your web web.config is copied.
Then VS spools up a WHOLE running copy of IIS (it is the express version - but it is the same for the most part as the full edition of II).
Once VS spools up and starts and configures that running copy of IIS?
Then your web page and web application can run. If you look at your system try, you see this:
So in above that 2nd from the left in the tray shows that blue thing icon. I have right clicked on it to show the options you see.
So now you have a running copy of IIS on your computer. So you ARE running a full web server here. (well, ok IIS express - but the base parts and what that means is much the same as the full edition).
Around about VS version 2010, they USED to have a smaller built in web server as part of VS. The problem of course was for Microsoft to maintain 100% compatibility was VERY hard. So while for a considerable time frame and history of VS? Yes, they had a built in web server as part of VS. But they dropped it a number of versions ago in VS, and as noted now use IIS express.
So Now? Well, when you install VS, they also install a working copy of IIS. (the express version). The express version is quite much the same as the full pop edition of IIS. What is removed is "most" if not "all" of the IIS management screens and setup. (and sometimes I wish they would just install that part too!).
Your experience thus that a copy of IIS is launched. Once launched IIS does keep running during your development process (depends on your VS config and setup). But, if you go file->close solution, then you find that IIS express then also shuts down.
So, to view that web page? Yes, VS does config, and then does spool up and start internet services and that web server. So this running of IIS on your computer is what allows those web pages to work and run correctly. As noted, while this is a copy of IIS, it is for the most part the same as the full edition - just with most of the management tools removed. As noted, you SHOULD see that new icon appear in the system tray.
And as noted, I believe around VS 2010, they made that switch from the VS built in IIS to that of now using IIS express edition. As noted, this change was made to ensure a greater probability that when coding and debugging your web site in VS, that the end result will be much the same when running a full edition.
I do find that over time, the production (web hosted site) does get so many config and tweaks and changes, that I now can't include my web.config file in the publish (can't risk overwriting the server production web.config). So, over time, we added things like https security certificates and installed them, and set them up for the production web site. I don't have those same security certificates setup on my local machine. And of course there are some virtual folders and few more things that exist on the production web site as opposed to the dev copy I use. So, it somewhat my fault to let the production web.config over time to become "different" then what I run local when coding and debugging the web site. So now, when I publish - I remove the web.config file before I actually copy the new updated web application to the final production server (which of course is running the full edition of IIS).
But to make a long story short?
Yes, a whole copy of IIS web server is configured for you, and that whole copy of IIS is spooled up, launched, and once that occurs, then your web page option "view in browser" can run. But make no mistake here - IIS services is setup, is started, and is running for that web page preview to occur.

Visual Studio 2010 displays IIS 7 page on debug instead of my project

This is my first ASP.NET project so I am a bit of a rookie when it comes to a lot of the configuring of IIS/Visual Studio so bear with me...
I am using Visual Studio 2010 running on Windows Server 2008 SR2. We recently did some updates on the server and now my project no longer loads when I attempt to debug. When I try to debug the default "Welcome" page for IIS 7 loads instead of my project. I am set up to use the development server to debug, not IIS so I don't understand why I get the IIS page. Before the updates the debugger was pulling up my page without any issues.
Any ideas? Thanks in advance!
It looks like IIS is now bound to the port number that Visual Studio Development Web Server was using previously. You can change the port number in the properties of the web site project.
I have found a solution to my issue. I decided to use IIS instead of the Development Server for debugging. After attempting to debug unsuccessfully yet again, I took a look at the identity that was being used in the application pool and I changed to one with more privileges and that seemed to do the trick. Thanks for the suggestions.
I had the same problem but non-of the earlier answers worked.
I am using Windows 7 enterprise 64-bit, IE11, VS2010, Silverlight 5
I have been developing and maintaining a number of Silverlight projects for the past 5 years, and have always been able to debug them within VS2010 using the ASP.NET Development Server. However, on returning from some well deserved holiday, I found that none of my existing Silverlight projects would run in the debugger. In each case there is a Web project set as the start-up project, and in each case on starting the project within VS2010 (with or without debugging) I got the IIS7 web page instead of my application.
I tried creating a new Silverlight web application, and found that this started normally in the ASP.NET Development Server. I checked my source code and found that no changes had been made in my absence.
After a lot of head scratching, etc., the solution was to clear the IE cache. These are the explicit steps I used:
Close all instances of IE and ASP.NET Development Server.
Open Internet Properties from the Control Panel.
Click "Delete" on the General Tab.
In the Delete Browsing History box check the following options:
a) "Preserve Favourites website data"
b) "Temporary Internet files and website data"
c) "Cookies and website data"
Leave the others unchecked
5) Click "Delete" and wait for the command to complete.
6) Close the Internet Properties box.
7) Rebuild ASP.NET project
8) Start (with or without debugging) in VS2010 - it should now load normally.
Hope this works for you.

Debugging ASP.NET in IIS 7

I have searched all the usual but come up empty. I must be doing something silly!
Simply I created a new project, ASP.NET Web App, and wish to use and debug it with the local install of IIS 7.5 on my Windows 7 x64 box.
According to what I have read it should be a simple process; my issue is that Visual Studio will not stop at breakpoints nor at errors etc.
I just don't get it:
Visual Studio is attaching to the w3p process for me automatically.
If I hover over the breakpoints it shows a message saying the same, that it is in the same w3p process.
I am in Administrator context. I manually ran it like so to be sure but in any case if you are an admin it runs like that anyway.
Some notes:
I do not wish to use IIS Express as I require native IIS 7.5 for my tasks, however it does debug in express - no surprise there.
As mentioned above, all this is being done locally.
The path of the virtual directory is pointed towards the project files, as set by Visual Studio 2010. It even set the Network Service as read on the folder structure.
When debugging from VS the web site runs fine, just debugging is the issue.
Maybe it is permissions? The Default App Pool is using the ApplicationPoolIdentity not Network Service... Should it be? I had assumed they we.re one and the same essentially. Although I changed this and no luck unless I didn't do something I should of
Keep in mind here that my issue is semi-unique in that I am not receiving error messages, not even in the event logs... For all intents and purposes it should be working fine, just it isn't.
VS and IIS, and all updates, are applied to date.
Note: I'm familiar with IIS7.5, I run my own public web hosting server. I just never tried to debug
Note: It is Visual Studio 2010 Ultimate
Thanks for your time.
Sigh!
I went back to basics... Uninstalled IISExpress and tested; It worked! Re-installed IISExpress; It worked!.
I guess installing IIS7 native after IISExpress did something screwy? I had ran the register ISS command on IIS7 when I installed it.
Right, so now I have both installed in tandem and they work fine. Thanks for all your help guys, appreciated.
you can try right-click on project in VS go to properties select web from left menu tab. Check if ASP.NET debugger is checked and also you can select Use Local IIS Server and give localhost url there (in project Url textbox) and then Say start debugging from VS and put breakpoints.
I had a similar issue the other day, I attached the debugger to the wrong w3p process, make sure you attach it to the one the app pool identity is running under.
I wanted to write it as comment by I don't think I can add pictures..
Are you sure you are running the same version of dll?
Is your breakpoint filled like this?
or hollow like this?
1st go to ,Program and Feature in control panel and then in that turn on or off windows features. and now check all check boxes(activate features) related to Internet Information server & windows service managers. once this is done run your visual studio as administrator and then attach to right w3p process.

What are the (dis)advantages of using Cassini instead of IIS?

I've found that on some occasions I can edit the source while debugging. Are there any other advantages of using the Visual Studio built-in webserver instead of a virtual directory in IIS?
I'm using Windows XP on my development environment, and a local instance of IIS 5. I work on several projects, so I use multiple virtual directories to manage all the different sites.
Are there any disadvantages?
The built-in web server for Visual Studio is called Cassini and here are a few of its limitations...
It can host only one ASP.NET
application per port.
It does not support HTTPS.
It does not support authentication.
It responds only to localhost
requests.
It is slow startup compared to IIS
All the previous responses are great answers - here's one gottcha with Cassini that might require IIS on the destkop.
Cassini runs in the context of the developer, not as the IIS user (IUSR_, IWAM, or in WinXP x64, the w3wp process). This can be a bit painful if you've got a web site that is accessing external files or creating temp files. It is most evident when your developer is running as an Admin of their desktop.
When you move to the server IIS, something that you would have had access to in Cassini doesn't work the same. CACLing with the IIS_WPG usually is all it takes to fix, but if your developer is not thinking about this, they will quickly get quite frustrated with their deploy.
Cassini does not support virtual directories.
It looks like a third option is coming soon:
IIS Express.
Another disadvantage I've run into is on a Forms authenticated website using custom IPrincipal/IIdentity. Cassini will switch the AppDomains without warning (or notice).
Check this blog post for more.The headache on this made me drop Cassini and stick with IIS.
The Visual Studio web server is less forgiving about // in the path.
It will refuse to serve a link like
http://localhost:52632/main//images/logo.jpg where IIS will do.
That's pretty obscure, but it means we have a lot of fixing to do to get rid of all the // occurrences.
The built-in server works well for larger corporations that don't want to give developers any administrator access on their own machines to configure IIS.
There's a bug in the way the built-in server handles HTTPModules - there is a workaround, but I hate having to put in code that'll never be needed in production.
You need to have Visual Studio running to use it (under normal circumstances)
It only responds to localhost, so you can't give the link http://simon-laptop:37473/app1 to a friend to view your site over the network
Big disadvantage: it's harder to get fiddler working, because localhost traffic isn't sent through the proxy.
Using http://ipv4.fiddler:37473 is the best way to get Fiddler working with it.
You cant use virtual directories :(
Cassini also does not support ASP Classic pages. This is only an issue for legacy projects where old ASP Classic pages still exist (like our web application at work).
The built-in server means the developer doesn't have to know how to set up IIS to test their site.
You could argue this is a disadvantage, and that a Windows developer should know at least that much IIS. Or you could argue that a developer who isn't a system administrator shouldn't be messing around with the web server at all.
If you 'web reference' the URL for web services that are on the built-in webserver, the port might change. Unless you have set a "Specific port" mentioned in menu Project → Properties options page.
This is something I've gotten used to now. I always set a specific port. Now when sometimes the webserver crashes (I've had that happen), I simply change the port number, and all is well. I reckon restarting will also fix this.
If you do hobby work at home using XP Home, you can't install IIS locally.
When you use IIS in Vista or Windows 7 with UAC enabled, you must run Visual Studio with administrative rights. If you do this, you can't drag an drop from your shell to Visual Studio (even if you run an instance of explorer.exe as administrator).
For this reason I use Cassini for most projects.
FYI, Windows XP 64-bit comes with IIS 6.
This is an old thread started 2 years ago. I just stumbled upon UtilDev Cassini while googling. Looks promising to me. At least it has the ability to run multiple sites simultaneously. That feature is really useful for me, because I work on 2 different sites and have to continuously switch between them using IIS.
Here's a reason for a third way: although UWS Pro is probably closer to IIS than Cassini (although inspired by Cassini and is from the vendor of the UltiDev Cassini fork), its main purpose is to be redistributable along with ASP.NET applications.
Cassini is meant to be a lightweight test webserver. The idea is that a developer does not need to have IIS installed and configured to test his/her application.
Use IIS if you are familiar with it and you have it set up and your box can handle it. Cassini is not meant to be a replacement.
I often take the best of both worlds and create an application in IIS, and use the built-in web server for more efficient debugging.
The built-in server isn't as configurable, and it runs on an odd port, so if you're counting on specific behavior it can be troublesome.
Install IISAdmin, and you can setup separate sites in IIS 5, instead of using virtual directories.
The built-in webserver is a little less robust than IIS, but requires no setup so it is just a tradeoff.
You may not always want your development projects exposed on your IIS server (even your local IIS server) so the built-in server is good for that.
However, if your application is going to access resources outside of the norm for a web app then you may want to debug frequently in IIS so that your app will run with restricted permissions and you can see where the pain points will be.
One difference I've found is that the development server handles uploading files differently than IIS does. You can't trap the error if the file being uploaded is bigger than your Max_File_Size setting. The page just dies and returns a 500.
Another dis-advantage is that it sends every request through the gloabal asax file which includes all requests for images and stylesheets. This means if you have code in there which does things with the file names, such as a look up, then the auxillary files willget processed too.
Also via IIS, you don't have to worry about automatically remembering and setting a stupid port number in your localhost url. That's something funky directly relied upon with Cassini...big pain in the ass. Who wants to remember some abritrary port number. Just run the damn site in IIS..plain and simple.
We've also seen some issues with Visual Studio built-in server regarding some third-party controls which put their scripts in the \aspnet_client folder.
Since the folder isn't there when you're not running under IIS, the controls didn't work. It seems a lot simpler to always work with IIS and avoid strange problems.
If your project resides in the IIS directory you can still edit code. It just depends if it has been published or not.
You will run into so many issues on the Cassini vs. IIS when you are debugging certain permission based scenarios, like Kerberos and NTLM authentication as well as issues like server compression, etc. All in all, the Cassini is still okay to develop with, but make sure you do extensive testing when publishing to IIS.

Resources