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

前端 未结 26 1498
醉酒成梦
醉酒成梦 2020-12-07 07:30

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

相关标签:
26条回答
  • 2020-12-07 08:19

    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!

    0 讨论(0)
  • 2020-12-07 08:19

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

    iisreset
    
    0 讨论(0)
  • 2020-12-07 08:21

    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>
    
    0 讨论(0)
  • 2020-12-07 08:24

    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.

    0 讨论(0)
  • 2020-12-07 08:28

    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.

    0 讨论(0)
  • 2020-12-07 08:29

    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.

    0 讨论(0)
提交回复
热议问题