The Web Application Project [...] is configured to use IIS. The Web server [...] could not be found.

I have a web project in my solution file that is "unavailable" when I open the solution. When I right-click on the web project and reload the project, I get the following error:

The Web Application Project mycompany.myapp.mywebproject is configured to use IIS. The Web Server 'http://localhost/MyWebApp could not be found.

I have not manually set up virtual directories for this web application.

Per colleagues, Visual Studio should prompt me to create virtual directories but I am not getting prompted.

I installed VS2010 before installing IIS on my dev machine.

Here is my development machine setup:

  • Windows 7 Enterprise
  • Service Pack 1
  • 64 bit OS
  • Visual Studio 2010 Enterprise Service pack 1
  • IIS version 7.5

Solution 1:

Since the accepted answer requires IIS Manager, and IIS Express doesn't have IIS Manager or any UI, here's the solution for you IIS Express users (and should work for everyone else too):

When you open Visual Studio and get the error message, right-click the project Solution Explorer and choose "Edit {ProjectName}.csproj"

In the project file, change the following line:
<UseIIS>True</UseIIS>
to
<UseIIS>False</UseIIS>
Save the file.

Now reload your project.
Done.

You'll then be able to open your project. If at this point, you want to use IIS, simply go to your project properties, click the "Web" tab, and select the option to use IIS. There's the button there to "Create Virtual Directory". It may tell you that you need to run Visual Studio as an administrator to create that directory, so do that if needed.

Solution 2:

Open the project folder and delete {Project}.csproj.user, then reload the project on Visual Studio.

Solution 3:

When this happens the easiest solution is to make the virtual directory manually.

First of all, you need to make sure you have the right version of ASP.Net installed and that you have installed the IIS extensions.

To do this, go to the relevant .net version's folder in C:\(Windows)\Microsoft.NET\Framework\(dotnetver)\ (substituting the bracketed folders for the right folders on your PC) and run this command

aspnet_regiis.exe -i

Next once that's run and finished, sometimes running

iisreset

from the command line helps, sometimes you don't need to.

Next, go to your IIS Manager and find you localhost website and choose add a folder. Browse to the folder in your project that contains the actual ASP.Net project and add that.

Finally, right click on the folder you added and you should have an option that says 'convert to application' or 'create virtual directory' or something similar.

!!Make sure the Virtual directory has the name 'MyWebApp'!!

Reload your solution and it should work.

Please be wary; this isn't a programming question (and shouldn't really be posted here) but I've posted this guidance as it's a common problem, but the advice I've posted is generic; the commands I've listed are correct but the steps you need to do in IIS may vary, it depends on your version and your account privileges.

Good luck!

Solution 4:

This solution worked for me: Right click the Project and select edit and find the following code as shown below in the picture.

change the <UseIIS>True</UseIIS> to <UseIIS>False</UseIIS>

OR

change the <IISUrl>http://example.com/</IISUrl> to <IISUrl>http://localhost/</IISUrl>

csproj screenshot