76

I recently renamed my root TFS folder from D:\TFS\systemstfs to D:\TFS\sys because one of the project's paths was too long for Windows. Now, when I attempt to run a different project (D:\TFS\sys\companydomain.com\Dev\Flowers\wsBusinessLayer) in VS2013 using IIS Express (Project URL http://localhost:59729/Flowers/wsBusinessLayer/) I get the following error message in the browser:

HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.

Module - IIS Web Core
Notification - BeginRequest
Error Code - 0x80070003
Config Error - Cannot read configuration file
Config File - \?\D:\TFS\systemstfs\companydomain.com\Dev\Flowers\web.config
Requested URL - http://localhost:59729/Flowers/wsBusinessLayer/InformationServices.asmx
Physical Path - D:\TFS\sys\companydomain.com\Dev\Flowers\wsBusinessLayer\InformationServices.asmx

(emphasis mine, D: is the second HDD on my machine, not a network share)

It's clear to me what the problem is (the config file path is wrong) but I have no idea how to fix it. I have tried:

  • Enabling "break on CLR exceptions when thrown"
  • Re-getting the solution from TFS
  • Rebooting
  • Switching to use IIS and then back to Express
  • Googling 500.19, 0x80070003, wrong path, cannot read configuration file, and various combinations of those terms

But have had no luck. Has anyone come across this before?

Vitani
  • 1,594
  • 1
  • 14
  • 28

15 Answers15

107

Here is another possible solution that doesn't involve fishing for the applicationhost.config file:

  • Right click Web Project > Web > Project Url > (e.g. 'localhost:5459') and then increment the port number which will force a new entry in that file.

In my case I also needed to change authentication mode which can be done via:

  • Select Web Project > press F4 > set Windows Authentication as needed (enabled in my case).
Jeroen
  • 60,696
  • 40
  • 206
  • 339
Sonic Soul
  • 23,855
  • 37
  • 130
  • 196
33

Turns out I had to edit %USERPROFILE%\Documents\IISExpress\config\applicationhost.config in the following way -

<configuration>
  <system.applicationHost>
    <sites>
      <site name="wsBusinessLayer">
        <application path="/">
           <virtualDirectory path="/Flowers" physicalPath="D:\TFS\sys\companydomain.com\Dev\Flowers" />

I don't know how this file gets changed "properly", but editing it manually worked fine.

John Leidegren
  • 59,920
  • 20
  • 131
  • 152
Vitani
  • 1,594
  • 1
  • 14
  • 28
  • 7
    This is the global config file used by Visual Studio 2013 (and lower). VS2015 uses per solution config file, but still you need to manually edit the file if you change the source code path. – Lex Li Jun 13 '16 at 15:23
  • I think it gets edited through other TFS members when editing something in .csproj file of WebApplication – Aamir Masood Jul 05 '16 at 06:24
  • 6
    For those running into this issue, the **applicationHost.config** file is located at _C:\Windows\System32\inetsrv\config_ – MPaul Jan 23 '17 at 19:48
  • 2
    Visual Studio 2019 now stores `applicationhost.config` within the user projects files, see https://stackoverflow.com/a/12946477 – Dave Anderson Apr 22 '21 at 01:23
23

In my case, the wrong path was recorded in a .vs folder in the zip i received from colleague. Normally, I'd get source through source repository where .vs is not checked in.

Deleting the .vs folder resolved the problem for me.

Anders Juul
  • 2,407
  • 3
  • 34
  • 56
  • 6
    Thanks! Deleting only my `.vs\config\applicationhost.config` worked better – E. Sundin Feb 26 '18 at 14:59
  • This does the same thing as editing it and setting the values properly (like from the above answers). It's actually easier to just remove it and have it be generated in a valid state. – Alternatex Jun 30 '18 at 12:18
  • That did it for me .. the dreaded .vs folder corrupt again – RJ. Mar 08 '21 at 18:41
14

In my case, the following changes resolved this error:

Open applicationhost.config file from [SolutionFolder]>.vs[Hidden Folder] and change the value of overrideModeDefault attribute in windowsAuthentication section from Deny to Allow. As shown below.

Zeugma
  • 31,231
  • 9
  • 69
  • 81
Mahesh
  • 309
  • 4
  • 8
  • 1
    Legend! I had to change the "virtualDirectory" applicationhost.config. I didn't even know it exists in the .vs folder. – dtroy Jan 17 '18 at 04:18
  • Thanks a lot. I didn't know that iis express create another config file under solution directory! – sintetico82 Feb 13 '18 at 13:36
9

Changing the port number on my MVC project resolved my issue. I went in circles for over an hour looking for an answer. Thank you Sonic Soul.

It always amazes me when one tiny tweak can fix something horribly broken.

I incremented the port number and the error magically resolved.

Project Properties > Web > Project Url 

Using Visual Studios 2015.

DimaSan
  • 12,264
  • 11
  • 65
  • 75
2

If you are using Local IIS Web Server, rename the custom virtual directory, save and try again. After this, you can put back the original name.

Jeferson
  • 109
  • 4
2

If using a Virtual machine with "Shared Folders" -- I was using Workstation Pro to share the folder. When the project was in the "Shared folder" that was hosted on the HOST PC I was unable to run the project. Moving the project to a "Local" Drive resolved for me.

1

In my case, I received a new machine but when I try run the source (which is copied from old machine) got this error. Removing applicationhost.config file from .vs\config folder under the source code directory fixed the problem.

Shan
  • 23
  • 1
  • 5
0

I got the same error on IIS 8.5 (not express)

For me it was because I had replaced the folder with a copy and renamed it while IIS was running. For some reason it kept erroring out. I had to remove the website definition from IIS and re add it to get it to work.

Vaibhav Garg
  • 3,630
  • 3
  • 33
  • 55
0

Had the same issue today.

Change that caused the issue

Moving functionality from a separate controller to home controller. I literally moved a view and the functionality behind it from Controller'X' to HomeController

Nature of the issue

  1. Everything works fine when run via IIS express/ Visual Studio
  2. Every thing works fine when deployed locally to IIS.
  3. Hell breaks loose when deployed to the Deployment machine.
  4. Works fine if I deploy to a 'new Site' in Deployment machine's IIS.

Fix

  1. delete the Site/application pool instance from IIS.
  2. Recreate them.
  3. Deploy.
Supun De Silva
  • 1,437
  • 9
  • 15
0

In my case I replace .. in my path with a normal folder path.

TL;DR

I did the "clever" trick of utilising the relative path of my script file as I did not want to hard code my folder address.

"C:\Program Files\IIS Express\iisexpress.exe" /path:"%~dp0..\Lagardsdorren\bin\Debug\netcoreapp2.2\publish" /port:44342

I knew, but it took my some time to realise, that .. is non grata in IIS(express) as it makes it possible to path yourself out of your sites home directory. In my case it didn't but I guess IIS(express) just stops anything with .. in it.

I don't know how to get back to my clever relative path, but that is for another question.

LosManos
  • 7,195
  • 6
  • 56
  • 107
0

I solved this by going into the project properties > Web > and clicking "Create virtual directory" then I didn't have to change my ports.

JacobIRR
  • 8,545
  • 8
  • 39
  • 68
0

My setup is a .NET 4.6.1 MVC project hosted as an Azure Cloud Service. I got this error when running locally with Visual Studio 2019 and IIS Express. I was able to fix the error. In my case the error was a red herring and was a symptom of another problem. For me, I had to remove my references to System.http.net, System.runtime, and System.Runtime.InteropServices. Then I added the latest version of those those three references back with Nuget.

The issue was that my code could not find those three packages. It has issues finding the packages every time I switch my git branch, but that's a completely separate error, and one I'm still trying to resolve. The way I figured out what was wrong was I would run the code and look at the "build" and "debug" output in Visual Studio 2019. I saw errors relating to the code not being able to find System.Http.Net, so I fixed that, then saw the errors with the other packages and fixed them. The real issue was that my code was getting exceptions and not running correctly, it just happened to manifest as this 500.19 error.

Another possibly contributing factor is that I disabled "just my code" earlier in the day. This seemed to cause my code to not break when exceptions were encountered. Once I turned this back on, my code would break when an exception happened, and this also helped me figure out the cause of the problem. To find this option, go into Tools > Options > Debugging > General > "Enable Just My Code".

Original error: enter image description here

Brendan L
  • 1,436
  • 14
  • 13
0

for me it happened because i rename one of path folders and get project from github. go to

Right click on your startup project > project properties > Web > click on Create Virtual Directory

it replaced old virtual directory with the new one.

enter image description here

vajihe
  • 25
  • 9
-1

I got this error while getting code from my colleague and it was referring her path. I tried checking the path in whole application folder but couldn't. So I again got the code from different source other than my Colleague.

Shilu
  • 1