Tuesday 19 January 2010

Classic ASP in Visual Studio 2008 on IIS6 and IIS7 on Windows XP and Windows 7

I had to migrate a couple sites in classic ASP. I also had to make some modifications. I had to do these on  Windows XP (IIS6) and Windows 7 (IIS7) so I thought I'd write a post before I forget how to do it all.

Classic ASP in Visual Studio
Visual Studio 2008 has great intellisense for html, javascript etc. so it's definitely one of the nicest options for an IDE. According to a few posts I saw, you need SP1 for Visual Studio 2008. I already had it installed. 


In Visual Studio 2008, create a new Website (NOT Web Project). It does not make sense to create a Web Project because ASP doesn't require you to compile it. Likewise. "Websites" in Visual Studio 2008 are not precompiled before publishing. Copy the site to the root folder. In Visual Studio click the refresh button at the top of the Solution Explorer.


As far as I'm aware (correct me if I'm wrong), you cannot run ASP on Cassini (Visual Studio's lightweight web server). So you have to run your site using IIS (install it form your windows disk if you don't have it).


If you're running Windows XP, here is a nice tool that enables you to set up multiple of sites in IIS. Note that you can only have one site started at a time, however if you're constantly having to switch between sites you're testing/developing etc then this tool is rad!


Running Classic ASP in IIS
In IIS6 and 7, "enable parent paths" is disabled. You must enable it for your website, otherwise your ASP pages that access files in their parent folder (e.g. trying to access ../some_file.asp) will throw an error.


In IIS6 (Windows XP)
  1. Right-click the website, and then click Properties.
  2. Select Home Directory, and then click Configuration.
  3. Click Options, and select the Enable Parent Paths check box.
In IIS7 (Windows Vista and Windows 7)
  1. Click the website, and then click ASP (under the IIS section)
  2. Under Enable Parent Paths (5th item in Behavior section), select true.
  3. While you're there, select Send Errors To Browser (so you can see any errors)
  4. Click Apply.
Note that in II7 you have to install ASP as it is not installed by default. It's real simple. Just do the following:
  1. Go to Turn Windows Features on or off under Programs and Features (control panel).
  2. Expand Internet Information Services, then World Wide Web Services, then Application Development Features.
  3. Select ASP, and then click OK.
Now assuming you pointed the IIS to the correct folder, you should be able to see your website in your browser (in anything other than IE6) via http://localhost


I hope this was informative. If I left anything out, please let me know.



No comments:

Post a Comment