CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Jeffrey Palermo (.com)

Blog moved to www.jeffreypalermo.com

How to develop an ASP.NET web project without IIS binding - level 200

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.

 



Comments

joeyDotNet said:

Figured I would repost one of my postings from my old blog to go along
with Jeffery Palermo's latest...
# July 25, 2005 7:02 PM

Christopher Steen - Learning .NET said:

Ajax.NET for Microsoft ASP.NET 2.0 (beta)
BackgroundWorker and Web Services
Data Source Controls...
# July 25, 2005 8:57 PM

Christopher Steen - Learning .NET said:

Ajax.NET for Microsoft ASP.NET 2.0 (beta)
BackgroundWorker and Web Services
Data Source Controls...
# July 25, 2005 9:00 PM

Christopher Steen - Learning .NET said:

Ajax.NET for Microsoft ASP.NET 2.0 (beta)
BackgroundWorker and Web Services
Data Source Controls...
# July 25, 2005 9:00 PM

Sam said:

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. :)
# July 25, 2005 9:40 PM

.Net Adventures said:

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.
# July 25, 2005 11:57 PM

Jeffrey Palermo said:

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.
# July 26, 2005 5:40 AM

Jeremy D. Miller said:

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.
# July 26, 2005 7:06 AM

Jeffrey Palermo said:

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.
# July 26, 2005 7:54 AM

John said:

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("<guid>") = "<project>", "<url here>",...
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
# July 26, 2005 11:19 AM

Jason Haley said:

# July 28, 2005 7:47 PM

Omar Villarreal's WebLog said:

I recently had to customize a Team Build script to build only one VS2003 solution and found that Nagaraju...

# March 27, 2007 5:49 PM

About Jeffrey Palermo

Jeffrey Palermo is a software management consultant and the CTO of Headspring Systems in Austin, TX. Jeffrey specializes in Agile coaching and helps companies double the productivity of software teams. Jeffrey is an MCSD.Net , Microsoft MVP, Certified Scrummaster, Austin .Net User Group leader, AgileAustin board member, INETA speaker, INETA Membership Mentor, Christian, husband, father, motorcyclist, Eagle Scout, U.S. Army Veteran, and Texas A&M University graduate. Check out Devlicio.us!

This Blog

Syndication

News

Headspring Systems

View Jeffrey Palermo's profile on LinkedIn

See my new blog at .jeffreypalermo.com