webinfo files simplify locating ASP.NET projects with Visual Studio .NET
If you’ve ever had trouble adding an existing web application to a solution when the application isn’t under the c:\inetpub\wwwroot folder, adding a webinfo file to the project may help. Typically I have this problem when I use source control to copy my development files to a new machine and need to re-establish proper registration with IIS. It sometimes seems simplest to remove references to projects in a solution that aren’t loading on the new machine and to add them again as existing projects.
The typical error message I get when adding the existing project is:
The project you are trying to open is a Web project. You need to open it by specifying its URL path.
The trick to successfully adding an existing project is to use a file path with a webinfo file instead of an http path, despite what the error message says.
When you create a new web application using Visual Studio .NET 2003 a webinfo file is created automatically for you. This file defines the web path to the application. If the file is missing, or the contents of the file no longer agree with the configuration of your web server, you will have trouble adding the project.
For example, say you have http://localhost/QEs as a virtual directory to “c:\Projects\Quick Experiments” and you have a web application in the folder “c:\Projects\Quick Experiments\WebApp1”.
The project filename is “WebApp1.csproj” and the corresponding webinfo filename is “WebApp1.csproj.webinfo” with the contents:
<VisualStudioUNCWeb>
<Web URLPath = "http://localhost/QEs/WebApp1.csproj" />
</VisualStudioUNCWeb>
Once you’ve added this file to the project folder, you should have no trouble adding the project to a solution by specifying the file path “c:\Projects\Quick Experiments\WebApp1\WebApp1.csproj”.
For no good reason of which I’m aware, this seems to work far more reliably than trying to add the project with the web path of “http://localhost/QEs/WebApp1/WebApp1.csproj”
Comments
Thanks for the fix. This page is the only reference to the issue (including MS' sites) I was able to find on the net. Best yet, the fix really works.
I had accidently removed the Front Page extensions from the virtual directories used by my solution. After I had reinstalled the FP extensions, I was no longer able to open the projects associated with the virtuals. I added .webinfo files in each virtual directory and I was magically able to open the solution without problems.
Thanks again,
Tom
Posted by: T@m Fel1z | March 23, 2004 02:12 PM
The solution you posted is by far the simplest way to add a web app to a VS.NET solution. The webinfo file you suggested worked without a problem. Thanks a lot!!!
Posted by: Jared | March 27, 2004 01:46 PM
Hi,
You code/article really helped me. It is very helpful.
Thanks and keepup the good work.
Thanks again.
So called Developer.
Posted by: Unknowm | March 31, 2004 12:42 PM
Just the tip I needed! Thanx!
Have a nice day!
Posted by: Lars Michael | April 7, 2004 11:43 AM
your article has been he most lepfull for me
I think it is better than even microsoft's own
Posted by: Tony | April 15, 2004 04:44 AM
Your hints have been very useful to me.
Thany you again!!
Posted by: Anig | May 20, 2004 10:06 AM
You help one more person again.
Posted by: YL | May 26, 2004 09:39 PM
Did i ever tell you youre my hero?
Your method is simple and it actually WORKS!
This is a really frustrating part of VS.NET, considering that recreating Web Projects on different machines should be a basic feature. THANKS AGAIN (sorry for shouting but you really have helped!).
Posted by: stever | June 4, 2004 11:34 AM
Thanks for the great article.
Posted by: Rohit | June 16, 2004 08:24 AM