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

29

330

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
Burson answered 4/6, 2012 at 22:43 Comment(1)
I had to run the solution as Admin so it could create the virtual directories..Neumeyer
S
90

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; 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.

Softspoken answered 4/6, 2012 at 22:53 Comment(11)
I followed the directions and getting the following error.. I deleted my virtual directory because of this error to begin with. Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to 'Telerik_Web_UI_WebResource_axd'Burson
What gives that error, IIS or Visual Studio when you start the solution ?Softspoken
Also, check the web.config for your new asp.net project, it make have two or more references to 'Telerik.WebResource.axd' it only needs one.Softspoken
I did check web.config.. when I remove the offending entry then I get the error message that the removed entry is needed.Burson
about to post a separate question shortly for the new error messageBurson
Did my help at least give you a virtual directory that you can use with your solution ?Softspoken
yes..it did.. I was able to set up the Virtual directory before but now I have a new problem that I just posted. #10890271Burson
Cool, at least we fixed one thing! I've commented in your new question.Softspoken
FYI, my "DefaultWebsite" was only configured to run on port 443 resulting in this same error message. I had to go to the Bindings and add port 80 to get it to work for me.Reactant
If this is something that was not happening, but then started happening, I suggest first trying to open VS as Administrator (as suggested below by kad81) I tried all of these things and it took time, when all I needed to do was open as Administrator.Infielder
I had to run the solution as Admin so it could create the virtual directories..Neumeyer
B
588

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.

Boys answered 17/10, 2012 at 8:28 Comment(8)
in VS2010 UseIIS is not in csproj file, but in .csproj.user fileUnchaste
In my case I still want to use IIS so I simply changed the URL, worked perfectly thanks.Caiaphas
I got this problem when upgrading & moving. This worked for me although since the solution wasn't loading I just opened the csproj in text editor. Thanks Doug.Diaconicon
This is the correct answer. The project is configured to use both IIS and IISExpress at the same time.Exerciser
And this helped me to add the port in IISUrl. ThxLebaron
Free UI for IIS Express: Webmatrix by Microsoft. microsoft.com/web/webmatrixAxiology
Using VS2013, I don't see Edit {ProjectName}.csproj when right-clicking on the solution. I accomplished the edit by going to the file system and manually editing the .csproj file. It was read-only, so I had to do a little dance, but it did work.Repeater
In my case, I had to edit the file projectName.csproj.user file rather than the projectName.csproj to say <UseIISExpress>true</UseIISExpress>Roi
A
263

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

Abyssinia answered 6/3, 2014 at 14:48 Comment(10)
I was the only one among our team that was seeing this IIS error. The dev team I work with had the same .csproj file from source control so the other solutions above were not what my problem was. It turns out the .csproj.user file you mentioned was causing this error in my situation. Thanks!Lissie
This worked for me after trying most everything elseMime
This is the correct answer. It resolves an issue with the configuration of the project on your machine (especially important when working with TFS).Villa
This is also the solution if you have set a custom iisurl tag but the project still starts on local host <IISUrl>MachineName.domain:12345/</IISUrl>Personage
This one worked for me. There was no <UseIIS> setting in my case.Cheviot
This worked like a charm for me. Like Matt, I had no UseIIS that the other answers suggested.Cyclothymia
This was the right answer for me. I had changed the web configuration of the project prior to reinstalling IIS Express, so that caused the bug.Killian
Excellent answer! Visual Studio 2015 crashed on me and seemed to mess up the project files that I had just changed from IIS Express to IIS. This fix worked for me.Tactic
Years have gone by, Visual Studio versions have changed, but this solution still works like a charm.Stefaniastefanie
This answer helped resolving issue in VS 2019 environment.Rigadoon
S
90

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; 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.

Softspoken answered 4/6, 2012 at 22:53 Comment(11)
I followed the directions and getting the following error.. I deleted my virtual directory because of this error to begin with. Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to 'Telerik_Web_UI_WebResource_axd'Burson
What gives that error, IIS or Visual Studio when you start the solution ?Softspoken
Also, check the web.config for your new asp.net project, it make have two or more references to 'Telerik.WebResource.axd' it only needs one.Softspoken
I did check web.config.. when I remove the offending entry then I get the error message that the removed entry is needed.Burson
about to post a separate question shortly for the new error messageBurson
Did my help at least give you a virtual directory that you can use with your solution ?Softspoken
yes..it did.. I was able to set up the Virtual directory before but now I have a new problem that I just posted. #10890271Burson
Cool, at least we fixed one thing! I've commented in your new question.Softspoken
FYI, my "DefaultWebsite" was only configured to run on port 443 resulting in this same error message. I had to go to the Bindings and add port 80 to get it to work for me.Reactant
If this is something that was not happening, but then started happening, I suggest first trying to open VS as Administrator (as suggested below by kad81) I tried all of these things and it took time, when all I needed to do was open as Administrator.Infielder
I had to run the solution as Admin so it could create the virtual directories..Neumeyer
G
45

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

Gigantism answered 31/7, 2015 at 13:32 Comment(1)
On a .NET Framework 4.5.2 project I just had to set the UseIIS flag to false.Guenon
P
40

For my project, I had to delete these two lines from .csproj file

<ProjectGuid>{3AA499DF-4A65-43B7-8965-D08A4C811834}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>

I tried deleting only the first one, but it wasn't enough.

EDIT: As many users have pointed out, this can change your project type or mess with your source control program. I can't investigate these issues as it was a school project I do not have anymore. Please be careful when trying this. At least make a copy of what you delete.

Pluri answered 22/1, 2017 at 15:5 Comment(5)
This one worked and this one should be marked as an answer. I tried many solution as suggested in SO but none worked for me except this one.Uticas
After trying all the suggestions above, this is the one that actually worked for me. Thank you my dude!Pouncey
This changes to project type so it's not a web application anymore.Tarra
It's not a good idea to remove <ProjectGuid> from .csproj file. To load the project it's enough to remove only <ProjectTypeGuids> which also is a bad idea as it changes the project type, as @Tarra mentioned. This answer is good if you don't want to commit your changes, just look into the code in VS.Marvel
This resolved the solution explorer load errors that I encountered with a contractor developed Visual Studio 2010 solution that I am moving to 2013. The solution file has 2 projects; a web app and a web service. I could not get either to load, so the Solution Explorer was only showing two empty folders after I attempted to open the solution file. Once I commented out the suggested ProjectGuid and ProjectTypeGuids lines, then I could see the dependencies of these projects in Solution Explorer. For me, this was a low risk high return option since I could easily undo these changes. Thanks!Beals
C
27

Edit the .csproj or vbproj file. Find and replace these entries

<UseIIS>true</UseIIS> by <UseIIS>false</UseIIS>
<UseIISExpress>true</UseIISExpress> by <UseIISExpress>false</UseIISExpress>
Consensus answered 26/10, 2013 at 19:20 Comment(2)
I also had to change DevelopmentServerPort to a value other than 80.Farmyard
And if you can't find the settings in the csproj file. Open .csproj.user file and do it there.Tadtada
E
13

Cause: The IISURL inside project.csproj is not correctly reflected in the project setting, and the virtual directory was not created.

Solution: Change the Project URL to correct PORT and create the Virtual Directory to make the missing PORT available.


Follow Below Steps:

Step 1: Right click on the project file to Edit the project.csproj file. enter image description here

Step 2: Search IIS and modify from <UseIIS>True</UseIIS> to <UseIIS>False</UseIIS> enter image description here

Step 3: Right Click Project to Reload the Project. After Reload successfully, right click Project and select Properties. enter image description here

Step 4: Locate Project URL option under Properties => Web enter image description here

Step 5: Change the Project URL to IIS URL indicated both on the Error Message and on the <IISURL>http://localhost:8086 </IISURL> from project.csproj file. Then Click Create Virtual Directory. Save All enter image description here enter image description here

Step 6: Redo Step 2 so it doesn't impact the remote codebase and the server deployment settings.

Explant answered 8/12, 2020 at 20:43 Comment(0)
B
12

In my case, this problem was caused by broken IIS bindings. Specifically, my 'http' binding had been deleted. Recreating it fixed the problem.

Bluebonnet answered 14/11, 2012 at 15:6 Comment(3)
I experienced a very similar problem. My HTTP binding seemed to rename itself one day -_- The project file setting for <IISUrl> had not changed (thank you SVN for confirming my memory and my sanity) but somehow the iis binding had. Fixed it up and the projected loaded right away.Grabble
Also, remember to check if you've changed target site's sni/hostname for some reason. This caused the error in my case.Luculent
In my case it was missing the HTTPS binding. I had to create the new binding and associate it with the IIS certificate.Acidify
H
9

This worked for me:-
Make all your IIS websites point to localhost(All Unassigned) only

enter image description here

Holomorphic answered 20/12, 2016 at 10:9 Comment(1)
This was already configured as you show, but the host name was empty. I found that changing it to 'localhost' corrected the issue on my machine, where all the .csproj files point to 'localhost/[vdirname]'. Thanks for the hint!Grannias
T
7

Try opening Visual Studio with Administrator privileges. In my case, it gave access to the IIS site and made this error go away. I was then able to switch the project to use IIS Express which doesn't seem to need administrator privileges.

Tintype answered 6/3, 2014 at 3:58 Comment(0)
C
7

If you are connected via TFS, open your project.csproj.user file and check for

<UseIISExpress>false</UseIISExpress>

and change it to true.

<UseIISExpress>true</UseIISExpress>
Chelsae answered 13/4, 2017 at 3:18 Comment(2)
Although i feel this is more of a workaround to the problem than the actual solution, gave it a thumbs up as it resolved my immediate concern.Whitewood
Worked nicely :)Blancheblanchette
D
6

You will not believe that, start visual studio as Administrator

as obvious from the message

The Web Server 'http://localhost/MyWebApp' could not be found.

could not be found because may it has no privileges to see it

so Just restart visual studio as Administrator

Dustpan answered 25/10, 2016 at 8:38 Comment(0)
I
5

You can load the project without setting the value of attribute UseIIS to true. Simply follow the below steps:

In the mywebproject.csproj file--

Delete the tag < IISUrl>http://localhost/MyWebApp/< /IISUrl> and save the file. The application will automatically assign the default port to it.

Indefatigable answered 6/9, 2016 at 10:27 Comment(0)
M
4

In my case I wanted to switch from http to https, so I had deleted http from IIS. In my .csproj.user file found that I still had:

<IISUrl>http://localhost/</IISUrl>

So I changed it to:

<IISUrl>https://localhost/</IISUrl>
Marna answered 30/3, 2015 at 15:44 Comment(0)
O
3

In my case I was able to open the solution in offline mode just running the command:

iisreset
Overplus answered 13/12, 2012 at 12:27 Comment(0)
M
3

For you Win8 users out there, if you follow the steps in the accepted answer, console spits out a message at you saying "thou shalt not use the command-line to execute this command" (paraphrasing). Instead, access the Programs & Features via Control Panel (or Windows + R > appwiz.cpl), click 'Turn Windows features on or off', and make sure you have the following installed:

Internet Information Services
  > World Wide Web Services
    > Application Development Features
      > ASP.NET 4.5

This will check a bunch of other options as well. As soon as I installed these features, and ran VS2012 with elevated permissions, I was able to launch my app successfully.

Mitchel answered 23/12, 2013 at 19:49 Comment(0)
P
3

This happens with me when I tried to open a project from the .csproj file, but I get over it by opening the project from VS:

File> Open> Web Site

and select the directory which include my project.

Pyrope answered 13/6, 2016 at 11:24 Comment(0)
P
2

I had this error, too. I thought everything was setup correctly, but I found out that one thing was missing: The host name I used for my project was not (yet) resolvable.

Since my app determines the current client's name from the host name I used a host name like clientname.mysuperapp.local for development. When I added the development host name to my hosts file, the project was loadable again. Obviously, I had to this anyway, but I haven't thought that VS checks the host name before loading the project.

Pachalic answered 9/10, 2013 at 9:14 Comment(0)
I
2

Check if IIS Express is installed. If IIS Express is missing, Visual Studio might discard the setting <UseIISExpress>false</UseIISExpress> and still look for the express.

Idolist answered 27/3, 2014 at 15:33 Comment(0)
I
2

in my case, make sure you have a "Default" website

Insulator answered 5/6, 2014 at 23:45 Comment(0)
S
2

In my case, the "Default Web Site" in IIS didn't have a binding for localhost on port 80. You should have a binding for whatever your value in the .csproj file is.

Stadia answered 6/12, 2016 at 6:38 Comment(0)
A
2

I fixed this simply by reinstalling IIS Express after downloading from below link:

https://www.microsoft.com/en-us/download/confirmation.aspx?id=48264

Amersham answered 14/9, 2017 at 3:25 Comment(5)
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From ReviewUniflorous
@Uniflorous I had the same error as the OP, I tried all of the other answers and nothing worked short of reinstalling IIS Express. So I believe this is my answer to the OP's question. Reinstall IIS.Amersham
Your answer was flagged as low quality and is going through a review process (note the "From Review" at the end of the comment). While it may work, reinstalling software is a last-resort option when nothing else works and isn't a specific solution for this OP's problem.Uniflorous
If it's a last-resort option after nothing else works—and according to Ajay2707 there is the potential for none of the other answers working for some poor soul—then I would think this answer could be useful. How can you designate an answer as low quality when it might be the only thing that works for some people? I support you Ajay2707. Thank you for taking the time to contribute to the community.Cott
Inb4 this conversation is moved/deleted as being low quality. viva la resistance!!Cott
T
2

Turns out my IIS was working on localhost:8181.Had to configure the {Project}.csproj file.

    <ProjectExtensions>
    <VisualStudio>
      <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
        <WebProjectProperties>
          <UseIIS>True</UseIIS>
          <AutoAssignPort>True</AutoAssignPort>
          <DevelopmentServerPort>7386</DevelopmentServerPort>
          <DevelopmentServerVPath>/</DevelopmentServerVPath>
          <IISUrl>**http://localhost:8181/ProjectName**</IISUrl>
          <NTLMAuthentication>False</NTLMAuthentication>
          <UseCustomServer>False</UseCustomServer>
          <CustomServerUrl>
          </CustomServerUrl>
          <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile><EnableWcfTestClientForSVCDefaultValue>True</EnableWcfTestClientForSVCDefaultValue>
        </WebProjectProperties>
      </FlavorProperties>
    </VisualStudio>
  </ProjectExtensions>
Telly answered 12/7, 2021 at 9:26 Comment(0)
H
0

In my case, the url referenced in the csproj file was incorrect.

It needed to be prefixed with www.

I made the changes, saved the file and the project loaded fine.

Harpsichord answered 27/11, 2014 at 12:2 Comment(0)
I
0

I ran into this issue when the <ProjectTypeGuids> element in the .csproj file contained the unit test project GUID: {3AC096D0-A1C2-E12C-1390-A8335801FDAB}.

Removing it made the project load without problems.

Ilyse answered 29/3, 2016 at 16:58 Comment(0)
C
0

For DNN users my issue was I needed a binding for dnndev.me at port 80. I have multiple installs that run on different ports and VS requires that that particular Url to exist on port 80 (not 86 like mine was).

Concerning answered 22/8, 2016 at 15:22 Comment(0)
T
0

Follow this completed solution step by step. it's works for me in VS 2017.

  1. Open Command prompt in administrator mode

  2. Open File explorer and got to .NET Framework folder

      Eg:C:\Windows\Microsoft.NET\Framework\v4.0.30319
    

    v4.0.30319 this is my .NET folder. you want to select your relevant folder.

  3. in CMD - Go to .NET folder path

    cd C:\Windows\Microsoft.NET\Framework\v4.0.30319
    
  4. Execute below command in CMD

    aspnet_regiis.exe -i
    

    You can see this message finally - Finished installing ASP.NET (4.0.30319.0)

    iisreset
    

    You can see this message finally - Internet services successfully restarted

  5. Open IIS in your computer (if not config Follow this)

    1. Go to Site and right click

    2. Add WebSite

    3. Fill - Site name and select physical path

    4. Then type port number (you can find port number in .csproj file and port number must equal with (IISUrl)

    EG : <IISUrl>http://localhost:15724/</IISUrl> my port is 15724
    

    Note : you cannot create port 80 number. because it used default IIS page

    1. Click Ok
  6. Open visual studio with administrator permission

  7. Then right click and reload your project

Your Problem may be solved.

Tray answered 23/6, 2020 at 3:4 Comment(0)
C
0

This may help some people in 2020. The main issue is that the IIS settings in the CSPROJ file don't match with the configuration for the machine. For example, if you had the Web Application Project pointing to localhost:12345, and a virtual directory isn't set up on the machine on that port, you'll get this error.

Using VS2019, I had this same issue, and the IIS settings in the CSProj file were being ignored. The reason for this is a new property in the CSProj file called "SaveServerSettingsInUserFile":

<ProjectExtensions>
    <VisualStudio>
      <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
        <WebProjectProperties>
          <SaveServerSettingsInUserFile>True</SaveServerSettingsInUserFile>
        </WebProjectProperties>
      </FlavorProperties>
      <UserProperties UseAjaxifiedTemplates="True" UseJQuerySupport="True" />
    </VisualStudio>
  </ProjectExtensions>

When this is set to TRUE, the IIS/Web server properties are in the

.CSPROJ.User file of the same project name.

This allows individual users of a project to have their own IIS settings, provided this file is not checked into source control.

You can control where the settings are stored using Visual Studio GUI in the properties for the project under "Web", "Apply server settings to all users"

web project settings

When this is on, the IIS settings are stored in CSPROJ, when off, they are stored in CSPROJ.User

Chellean answered 15/11, 2020 at 13:13 Comment(0)
D
0

I was having the same issues the steps tried and how it was produced

My application was working 5 minutes earlier than I install ADOBE photoshop with multiregional settings and delete temp folder by some command with force. which it ask then my project stop loading all of the web applications.

Steps have tried.

  1. Deleting .csproj.user file.
  2. Renaming IISExpress folder in C:/ProgramFiles/Documents/IISExpress
  3. Installing IIS then re-installing after restart
  4. Changing to Project extension with
      <FlavorProperties> 
        <WebProjectProperties>
            <UseCustomServer>False</UseCustomServer>
        </WebProjectProperties>
      </FlavorProperties>

The Web application was loading but it was legacy application and when was running gaving errors

So What have done is uninstalling VS 2019 and VS 2022 if installed then re-installed than it started working.

D answered 24/1 at 12:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.