ChatGPT解决这个技术问题 Extra ChatGPT

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


D
Doug S

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.


in VS2010 UseIIS is not in csproj file, but in .csproj.user file
In my case I still want to use IIS so I simply changed the URL, worked perfectly thanks.
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.
This is the correct answer. The project is configured to use both IIS and IISExpress at the same time.
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.
r
ruffin

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


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!
This worked for me after trying most everything else
This is the correct answer. It resolves an issue with the configuration of the project on your machine (especially important when working with TFS).
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>
This one worked for me. There was no setting in my case.
J
Jonathan S.

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!


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'
What gives that error, IIS or Visual Studio when you start the solution ?
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.
I did check web.config.. when I remove the offending entry then I get the error message that the removed entry is needed.
about to post a separate question shortly for the new error message
s
spottedmahn

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 True to False

OR

change the http://example.com/ to http://localhost/

https://i.stack.imgur.com/rSEag.png


On a .NET Framework 4.5.2 project I just had to set the UseIIS flag to false.
k
knightLoki

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.


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.
After trying all the suggestions above, this is the one that actually worked for me. Thank you my dude!
This changes to project type so it's not a web application anymore.
It's not a good idea to remove from .csproj file. To load the project it's enough to remove only which also is a bad idea as it changes the project type, as @Oram mentioned. This answer is good if you don't want to commit your changes, just look into the code in VS.
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!
d
dcaswell

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>

I also had to change DevelopmentServerPort to a value other than 80.
And if you can't find the settings in the csproj file. Open .csproj.user file and do it there.
R
Roger Lipscombe

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


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.
Also, remember to check if you've changed target site's sni/hostname for some reason. This caused the error in my case.
G
Gary Bao 鲍昱彤

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:

https://i.stack.imgur.com/rF42x.png

https://i.stack.imgur.com/e9zDK.png

https://i.stack.imgur.com/N6tKg.png

https://i.stack.imgur.com/3RMS4.png

https://i.stack.imgur.com/ncfBY.png

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


G
GorvGoyl

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

https://i.stack.imgur.com/sMME0.png


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!
k
kad81

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.


P
Patrick Dengler

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>

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.
Worked nicely :)
B
Basheer AL-MOMANI

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


Y
Yogesh Gangwar

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.


N
Njaal Gjerde

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>

C
Conrado Fonseca

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

iisreset

S
Scott Silvi

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.


m
mshwf

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.


f
fero

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.


T
Thea

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.


d
drew

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


D
Dan Mirescu

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.


A
Ajay2707

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

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


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 Review
@FluffyKitten 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.
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.
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.
Inb4 this conversation is moved/deleted as being low quality. viva la resistance!!
F
Faisal Ansari

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>

s
sharkbait

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.


M
MvdD

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.


M
Mickers

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


U
Udara Kasun

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

Open Command prompt in administrator mode 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. in CMD - Go to .NET folder path cd C:\Windows\Microsoft.NET\Framework\v4.0.30319 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 Open IIS in your computer (if not config Follow this) Go to Site and right click Add WebSite Fill - Site name and select physical path Then type port number (you can find port number in .csproj file and port number must equal with (IISUrl) EG : http://localhost:15724/ my port is 15724 Note : you cannot create port 80 number. because it used default IIS page Click Ok Open visual studio with administrator permission Then right click and reload your project

Your Problem may be solved.


L
LarryBud

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"

https://i.stack.imgur.com/d8xOW.png

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