Wednesday, February 21, 2007

Classic ASP (not ASP.Net) code debugging with VS Dotnet IDE 2005

I am not sure how many developers would need this but i needed it badly, i think i am the only one doing ASP coding and ASP.Net 2.0 coding at the same time :) So having used the 2005 IDE, you feel like your hand is broken when you go back to do classic ASP coding for old maintenance projects, where only way to debug is Response.Write but imagine how it would be if you can set breakpoint in classic ASP code and step in, step out F11, F10, Shift F11, F5 wouldn't it be great.

So i started my googling to find a solution which would make my daily coding life better and i was able to do it.

So here i am sharing my experience, "How to debug classic ASP using VS Dot net IDE 2005"

1) You need not have a sln or a project file, you can even open one single ASP file and debug it from top to bottom,
2) Open your ASP file in VS Dot net IDE 2005, then open IE and browse the page, this is done so that the ASP rendering process (IIS server but not aspnet_wp.exe, not w3wp.exe but dllhost.exe comes in to task manager),
3) Go to your default web site in IIS or your virtual directory >> right click properties >> home directory >> configuration >> Debugging tab >> in the debugging flags section,
check - Enable ASP server-side script debugging

In the script error messages section, check send detailed ASP error messages to client. (as shown in picture below).

4) Now comes the important step, open your vsdotnet ide 2005, and open the single ASP page and click Debug >> Attach to process >> check the check box [ ] show processes from all users, then look for a process called dllhost.exe Type = x86, Script and the username running it is YOURPCNAME\IWAM_YOURPCNAME.

Click Attach and wait for few minutes and click ok, now go back to your ASP page place a break point and then refresh the IE, and you should see it stops at the breakpoint.

Happy Debugging ASP :)

Tuesday, February 20, 2007

VSDotnet IDE 2005 making use of IIS instead of development webserver

How to use IIS as the default web server instead of inbuilt ASP.Net development web server
When you create a new web project in VS dot net IDE 2005, by default it uses the inbuilt ASP.Net development web server for debugging and running,

So the URL will be something like,
http://localhost:2500 or a dynamic port,

This is actually the internal development web server. But for developers who are familiar with using IIS this may actually be a head ache. Also if you are using port 80 to code certain applications or using AJAX with 80 port then it may be tough to debug using fiddler or in general to stop and restart. So it is better to use IIS.

Listed below are the series of steps which you can easily do to change it to use IIS,
1) Create a virtual directory on IIS and point it to the folder where the source code resides, for example I use D:\drive instead of C:\inetpub\wwwroot, so i create a Virtual directory called "WebSite1" and point it to D:\proejcts\dotnet\website1\ = the folder where the sln file and the vbproj or csproj resides.

2) Right click on the virtual directory tab and go to properties in IIS and click on ASP.Net tab, in the dropdown change the dot net version from 1.1 to 2.0

3) Then open your VS dot net solution file and right click on your project >> go to property pages >> click on start options to see a screen like the one shown below,

In the above screen, select Use Custom server, Base URL: http://localhost/website1
Now try debug >> start without debugging, you will be using IIS to render the page. Though this is simple it takes few minutes to ponder this setting.