When you create a new ASP.NET Web Application, VS.NET by default creates a folder with the specified application name under the Visual Studio Projects folder (typically under
However, you usually want to keep all your projects under a common folder, and have the source files together with the solution files (so that’s easier to move everything to another computer, for example), whether they are Windows or Web application, and thus don’t like VS.NET’s default behavior. It would be preferable to have the possibility to specify a virtual and a physical folder when you create the web application, but unfortunately this is not possible from the New Project dialog window.
The solution is easier than what you may think, though. Say that you want to create a web application named MyWebTest, and that you want to place all the source files (not just the solution files) under c:My ProjectsMyTestWeb. Here are the steps to follow:
- Create a Blank Solution in c:My ProjectsMyTestWeb, so that the solution files will be placed in a new folder with this name and in this location.
- From the IIS administration console create a new virtual directory named MyTestWeb that points to the physical folder created above. (Alternatively, you can create the virtual folder from Windows Explorer, through the Web Sharing page of the Properties dialog for the physical directory.)
- Add a new project of type ASP.NET Web Application to the blank solution, and in VS.NET’s New Project dialog use MyWebTest as project name. VS.NET recognizes that a virtual folder with that name is already present, and use it for the project, even if it points to a physical location that is different to that VS.NET would have used by default.