If you’ve every shared an ASP.NET project or worked on one on multiple computer, you know what a pain it is to ensure that all computers have the same IIS virtual directory configured. If you don’t, the project won’t open.
For ASP.NET 1.1, it’s easier to use a class library project instead of a web project. You lose a bit of designer support, but you gain project portability. If you are like me, you don’t use the designer at all, and it’s all gain and no loss.
The trick is to delete the *.csproj.webinfo file, take your web project and open the .csproj file in notepad. Then find the following at the top of the file:
<VisualStudioProject>
<CSHARP
ProjectType = “Web”
ProductVersion = “7.10.3077″
SchemaVersion = “2.0″
ProjectGuid = “{09E1A7E2-B51D-42EA-A2BE-4A5991BDF2A7}”
>. . . . . . .
And just change “Web” to “Local”
<VisualStudioProject>
<CSHARP
ProjectType = “Local”
ProductVersion = “7.10.3077″
SchemaVersion = “2.0″
ProjectGuid = “{09E1A7E2-B51D-42EA-A2BE-4A5991BDF2A7}”
>. . . . . <snip/>
Literally, that’s all it takes. Now your poject opens as a class library, and you just set up IIS to wherever the project is. You can debug just like before, and you can use pages and user controls just like before.
One note: Change the project type back to “Web” before upgrading to .Net 2.0 or the project conversion wizard won’t properly create a website.
If you ever need to move the solution somewhere else (I have to move from local to development for code review), you can change the sln file.
There’s a line like Project(““) = “
“, ““,…
change the url to the new server address and it will change the project file for you. If you just change the project, VS will complain about them not be in synch
The build doesn’t require a virtual directory. It’s just a class library build and a copy of the aspx files to the IIS directory. NUnit stuff is easier because NUnit can reference the class library.
Cool. You should probably still go to the headache to get the virtual directory setup in the NAnt build though. Did this make it any easier to run NUnit on the code? I’ve bumped into all sort of weirdness in the past trying to create classes in NUnit that are part of a web project.
Sam,
I have used Cassini to develop on XP Home edition, but I prefer IIS. For many.Net applications, Cassini works, but for more advanced apps, you need the configurability of IIS.
On this url (http://pluralsight.com/wiki/default.aspx/Fritz.AspNetWithoutWebProjects) you can find better way how to setup ASP.NET web project without IIS binding.
As a followup, you can also use the Cassini WebServer with the ClassLibrary tactic to avoid IIS completely. You can develop on XP-Home if you need to; you can check-in the Cassini executable and have everything you need to edit & run the project (as long as you install the cassini.dll to the GAC, or write a batch file to do it for you); you can just forget about IIS configuration issues and get to work faster. I personally wouldn’t go back to IIS.