HTTP error 500.19 - Cannot read configuration file

前端 未结 13 2224
醉梦人生
醉梦人生 2021-02-02 09:37

In one of my ASP.NET apps, all of a sudden I am unable to run it in Visual Studio 2013 due to the error displayed below. It appears that it is trying to open the web.config from

相关标签:
13条回答
  • 2021-02-02 09:57

    I changed the virtual directory path in vs\config\applicationhost.config inside the solution folder.

    0 讨论(0)
  • 2021-02-02 09:57

    Thank you PongGod!! I am not able to comment on your answer but I wanted to post anyway since I had the exact same issue while running an instance of Orchard. In my case, everything had been running great until I found a bunch of old project files located in:

    %USERPROFILE%\My Documents\My Web Sites\
    

    And started deleting them for no apparent reason. I then tried to start up Orchard from Visual Studio in debug mode and received the error message above. After applying the same fix to my applicationhost.config file, everything is working fine now.

    In my case, I am assuming that the directories got mixed up because I had initially ran the default Orchard files from Visual Studio and from Web Matrix. Then later on, I downloaded the full source files and began running the files from a completely different directory. Thanks again.

    0 讨论(0)
  • 2021-02-02 09:59

    I've been able to resolve this issue even though I can't say I fully understand all of the details. I'll attempt to describe the situation the best I understand it and hopefully others with greater insight can add further clarification.

    After having been doing all of my development on my workstation, it was suggested that I begin doing this work in a new VM environment that had been set up for me. So I installed VS 2013 there and copied my source code from various projects over there. However, rather than follow my previous local path convention of C:\Projects\SourceCode[ProjectName]... this time I decided to use the directories that are set up during the VS install, c:\users[MyUser]\My Documents\Visual Studio 2013\Projects[ProjectName]. Sometime shortly thereafter, our infrastructure team made a change so that my home directory, c:\users\rmayer, was now being pointed to a common network drive, \totalsafety\TSUsers\rmayer. Everything continued to work without any issues.

    However, due to various difficulties I had working in this VM environment, I decided to return to doing my development work on my workstation using the original local paths for my source code. This is when I began encountering the errors described above whenever I would try to run my code through VS. What I've begun to learn is that there is an applicationhost.config file that IIS Express uses located here: \totalsafety\TSUsers\rmayer\My Documents\IISExpress\config. It contains entries for each of my web projects; the one relevant to this issue had a section which looked like this:

            <site name="AFEManager.Web-Site" id="8">
                <application path="/" applicationPool="Clr4IntegratedAppPool">
                    <virtualDirectory path="/" physicalPath="C:\Users\rmayer\Documents\My Web Sites\AFEManager.Web-Site" />
                </application>
                <application path="/AFEManager" applicationPool="Clr4IntegratedAppPool">
                    <virtualDirectory path="/" physicalPath="C:\Projects\SourceCode\AFEManager\Trunk\AFEManager.Web" />
                </application>
                <bindings>
                    <binding protocol="http" bindingInformation="*:19257:localhost" />
                </bindings>
            </site>
    

    The physical path attribute listed under applicationPool="Clr4IntegratedAppPool" at that time was set based on the local path I had been using at the time I was working in the VM environment. Now that this one file is being shared regardless of whether I'm working locally or within the VM due to the move of the users' home directories, this path is invalid when I'm working from my workstation. By updating this path to C:\Projects\SourceCode\AFEManager\Trunk\AFEManager.Web, it now works correctly from my workstation.

    Again, I have a limited understanding of how this is supposed to work, but what it's telling me is that I will be unable to do development work from multiple environments (not that I want to any longer) unless the local paths are consistent between all of them. If I'm correct about this, this seems like a less than ideal design.

    0 讨论(0)
  • 2021-02-02 10:00

    You can change the path for the web.config to its real path in applicationhost.config file. This file is located in /.vs/config folder.

    After changing the path in this file, save it and restart the project, it solved my issue.

    This is happening because I have different work stations, but the project is saving in different folders.

    0 讨论(0)
  • 2021-02-02 10:00

    Most simplest way to solve this issue.

    Approximate reason to arise this error is copy project from another pc.

    Solution:

    • Step 01: Open your project folder by right clicking and choose Open Folder in File Explorer.
    • Step 02: Open .vs folder (Hidden Folder) and you will get 2 folder named config and another one is named as your_project_name/config.
    • Step 03: Both config folder will contain a file named applicationhost.
    • Step 04: Open both applicationhost file using notepad and find the directory showing in error screen (Config File \?\C:\User\hp\Documents\My Web Sites\YourProjectName\web.config)
    • Step 05: Just replace this directory according to your pc directory. Example, in my pc I have changed as below:

    C:\Users\Sydur Rahman\Documents\My Web Sites\MyProjectName-Site to C:\Users\hp\Documents\My Web Sites\MyProjectName-Site

    Note: Please make sure you have changed in both applicationhost file.

    That's all. Now your project will run as expected!

    0 讨论(0)
  • 2021-02-02 10:02

    I experienced the same issue and I resolve it quite simply. My issue was arose after when I perform a merge operation in git repository, after merge operation Visual Studio some how changed my default project URL to the default URL of my partner's computer from where he pushed the last time in to my repository. So here is how I resolved this error:

    1. Simply go to the properties of the project.
    2. From the left vertically aligned menu, select Web.
    3. After you will Project url and a text box containing the default port number, now just aside that textbox there is a button "Create Virtual Directory".
    4. Press that button and there you go. It will again point the default url the current working folder of your project.

    Hope it works for you all :)

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