I frequently create copies of Web projects to test locally on my machine either for pre-deployment testing or for distribution to other developers to make sure the project loads, compiles and runs correctly. Ideally I should be using a separate machine for this, but often there isn’t one available. Long story short local duplication happens occasionally.
So to test I copy the project to a new location or check it back out of source control in a new location. Now since I use IIS locally for testing rather than the VS Web Server, when I open the project I get a nice dialog that asks if I want to create the virtual, which is thoughtful enough in most situations:
If you click Yes Visual Studio appropriately creates your virtual directory for you and loads your project. Cool.
Except when you don’t want it to create a new virtual. So if I’m testing the Web app (or get it ready for re-distribution) I often end up with multiple instances of the same Web app on the same machine and in that case I really don’t want to create a new virtual. Unfortunately, if you decline to create the virtual there are no further options and the project unceremoniously isn’t loaded for you. Bummer.
The fix for this is easy enough: You can open up the project file and change the <UseIIS /> key to false:
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>False</UseIIS>
…
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
Which effectively changes the project to using built-in Web Server. Now you can re-open the project and it will load although you may have to adjust your security settings to work with the local server.
It’d be nice if VS would provide another option to make this change for you, if you don’t opt to create the virtual. Not loading the project because the virtual doesn’t exist is kinda lame, especially since the project is completely dropped from the solution and not even shown as an unloaded project. The VS workflow for this certainly could be better. If you decline to create a virtual the app should be automatically switched to use the local Web server or at the very least it should be added to the solution as an unloaded project so at least you can edit the XML right there.
The no-load seems especially unnecessary since IIS is required only to run/debug the project, not to actually loading or compiling the project which – unlike in VS 2003 – uses the file system to load the project.
Other Posts you might also like