One of the clear changes in Visual Studio from Visual Studio 2005, is the dependency of VS on IIS for creating websites/web applications. In VS 2005 until its SP1 you only had the choice to create Websites that use the local cassini web server for development purposes. The Web Application Projects allows you to create the legacy style of project based sites which can run on IIS.
From VS 2008, you can create both Web Application Projects as well as Websites that can run on Cassini i.e. without the dependency on IIS and the ability to create the webapp folder anywhere in your machine(Remember the days when you could only create a webapp on c: \inetpub\wwwroot coz, it required to fall into the IIS WebRoot to be able to run and debug apps locally)
In VS 2010, the option continues to be the same i.e. by default both Web Application Projects (WAPs) and Website projects don’t have a dependency on IIS. In fact, to create them on IIS, you need to do a little bit of work around.
Note that in all the following scenarios, we need to run VS 2010 in the context of an administrator since we are creating/running the apps on IIS. So, it would be important to start VS 2010 (click the start icon, type visual studio 2010 – right click on the list and select “Run as administrator” and click “Yes” for the User Account Control confirmation dialog)
Creating and Running Web Application Projects on IIS on development machine
First off, run VS 2010 as administrator and select “File – New Project” and specify the location to store the project. I have given c: \inetpub\wwwroot but you can even specify D: or any other location you want to.
Note that even though you created this in the webroot when you run the application as is, it would still chose to use the Cassini Webserver (you can see that the page that opens uses the URL http://localhost::PORTNUMBER as the URL format)
Close the web browser and come back to the Visual Studio IDE. From the tools menu, select “Project” – “<PROJECTNAME> Properties”
It would list the properties listing in the left and the property values in the right.
Select the “Web” tab in the listing.
In the bottom under “Servers”, select “Use Local IIS Webserver”
At this point, if you try running/building the app, it would alert you stating that the app though configured to run in IIS is not actually configured in the IIS as an application.
Say “Yes”and it would configure your app as an Application in IIS. Alternatively, before running, you can also click on the “Create Virtual Directory” while selecting “Use Local IIS Web server” in the previous screen.
Now, when you run the app, you will notice that the app is actually running on IIS since the URL would point to http://localhost/APPNAME and discard the port number that comes when running on Cassini.
When you go to the IIS Control Panel, you would also notice that the app is created in virtual directories listing and points to the folder where the physical files are stored (interesting, it automatically does the root folder mapping even though you create a deep folder structure such as E: \Folders\Projects\ProjectName\AppName.
You can use the same approach for migrating existing projects as well to IIS from the cassini web server.
Creating and Running Websites on IIS on development machine
Again, start Visual Studio in the context of an administrator.
In Visual Studio, select “File – New Website”
In the Web location dialog at the bottom chose “HTTP” instead of the default “File System” and specify a name to your website
That’s all is required in the case of website. It would automatically configure it to run on IIS instead of cassini as you can see when you run the app.
These steps could become a little tricky and hence thought a post is worth. Do share your comments/suggestions if any.