Thursday, February 19, 2009

Visual Studio Tips & Tricks #4:- Adding a new website mapped to IIS

How to create a new website which resides inside your solution folder as a web project but is automatically mapped to the IIS.Benefit  of this approach is that we will be using IIS as the web server to run and debug this website not the Cassinni web server which is the default in Visual Studio.Another benefit is that we will escape the problems caused by the port no's which Cassinni bring by default.Some of us who prefer to use Cassinni can go on with it no probs!!!.But personally i like that each of my website in my project is mapped to a virtual directory in IIS.

Another benefit of creating IIS mapped website's is that when you share you code and other people open the solution then it automatically creates a website on the localhost no need to again map it to open with IIS.So given here is a step wise process along with pictures to illustrate how it is done.

I personally prefer to add a blank solution and then add new website's and projects to it,you can go other way round by choosing to create a new website with the option in Project And Solution in the Options menu in VS2008 to always create a solution for a project or website.By default Visual Studio will not create a solution if you only add a website.

More information on how to create empty solutions and solution for only one web project refer to my article

http://smallworkarounds.blogspot.com/2009/02/visual-studio-tips-tricks-3-how-to-open.html

Now right click on your empty solution or solution to which you want to add the new mapped website.It will ask you few options and there will be  a drop downlist also from where you can select where you want to create new website.

iiswebstart

So here by default you will have filesystem, so go and change it to  "http" from the dropdownlist and then click browse.This will take you to another selection box where in the top right you will see 3 buttons:-

1.Create New Web Application

2.Create New Virtual Directory

3.Delete

So here from these 3 options just select the "Create New Virtual Directory" option

iiswebnew

Now it will ask your for Alias Name and the Folder,just go and give any name what you want your virtual directory to be named as and the map it to the folder where you have initially kept your solution.

iiswebsave

Press OK that's it now everytime when you click open your solution, it will check for the virtual directory if its there then well and good if its not there it will automatically create one for you.

Happy Programming!!!!

Submit this story to DotNetKicks

del.icio.usSave Total0 users

0 comments:

Post a Comment