Creating and running VS 2010 Web Application Projects and Web Sites on IIS instead of the default Cassini web server

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.

image

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”

image

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.

image

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

image

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.

Cheers !!

Print | posted on Sunday, July 18, 2010 11:30 PM

Comments on this post

# re: Creating and running VS 2010 Web Application Projects and Web Sites on IIS instead of the default Cassini web server

Requesting Gravatar...
The Cassini web server is slow and has some limitations (https, authentication, etc.) and this tutorial is very useful, thanks.
Left by Dicios on Jul 24, 2010 11:33 PM

# re: Creating and running VS 2010 Web Application Projects and Web Sites on IIS instead of the default Cassini web server

Requesting Gravatar...
Thanks for the post! it's little trick and can save hours of work time :)

Just a question. How can I configure VS 2010 so it creates applications/sites always on IIS?
Left by Zai on Jul 27, 2010 3:02 AM

# re: Creating and running VS 2010 Web Application Projects and Web Sites on IIS instead of the default Cassini web server

Requesting Gravatar...
Thanks for the post. I am starting on a RIA silverlight project and the website would not update using Cassini. I would make changes and none of them would show up using the local webserver. I changed to IIS and it's working now.
Left by Nigel Stratton on Aug 26, 2010 8:04 PM

# re: Creating and running VS 2010 Web Application Projects and Web Sites on IIS instead of the default Cassini web server

Requesting Gravatar...
I had the same problem with the update with Cassini. Thanks for the tip changing to ISS. Works smooth now.
Left by Camp on Sep 01, 2010 7:24 PM

# re: Creating and running VS 2010 Web Application Projects and Web Sites on IIS instead of the default Cassini web server

Requesting Gravatar...
Very useful.
It would be nice to see an article on doing this retrospectively.
As must demo code assumes Cassini; when I set the project to IIS it creates a virtual directory for the local project ie c:\your development\my project when what I need is c:\inetpub\wwwroot\myTestSite so I can practise publishing just the code and then connect to my VM via my host PC as a client.
Left by Hunt on Oct 16, 2010 5:41 PM

# re: Creating and running VS 2010 Web Application Projects and Web Sites on IIS instead of the default Cassini web server

Requesting Gravatar...
Hi,
I am creating and running http port service for windows mobile 7 application in vs2010.Same port i will run but port https.

Error: Website's security certificate.how to run clear this error or skip certifiate error. Pl help me
Left by Sivakumar on Dec 15, 2010 11:38 AM

# re: Creating and running VS 2010 Web Application Projects and Web Sites on IIS instead of the default Cassini web server

Requesting Gravatar...
Thank you very much, It is the interesting well written article. Very pleased me to read it. Especially because the example of work is there described with the appendix of visual studio 2010. This version is usefully and more comfortable as compared to previous versions. And apparently in the article with him as easy as anything to work. Separately thank you for a prompt to work with Cassini.
Left by college paper on Dec 27, 2010 12:50 PM

# re: Creating and running VS 2010 Web Application Projects and Web Sites on IIS instead of the default Cassini web server

Requesting Gravatar...
Very nice article.. keep posting
Left by Pravin Dhokane on Jan 18, 2011 4:02 PM

# re: Creating and running VS 2010 Web Application Projects and Web Sites on IIS instead of the default Cassini web server

Requesting Gravatar...
Thanks for the info! It's very helpful and easy to understand.
Left by Indiana Driver Safety on Feb 22, 2011 12:11 PM

# re: Creating and running VS 2010 Web Application Projects and Web Sites on IIS instead of the default Cassini web server

Requesting Gravatar...
How can use access database in a web application and change values in each record such as calculating prices = quantity * unit_price ? and update the records. Somebody can help me, please...!!!!
Left by Julio on Jun 09, 2012 7:41 PM

Your comment:

 (will show your gravatar)