178

I've searched and searched on Google, and I can't find anything that even seems applicable to my situation, let alone solves the problem. It doesn't matter which address in my website I try to navigate to (even addresses that don't exist give this error instead of a 404), I get the exact same message (the path is always '/'). Any ideas?

Server Error in '/' Application.

Failed to map the path '/'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.InvalidOperationException: Failed to map the path '/'.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 


[InvalidOperationException: Failed to map the path '/'.]
   System.Web.HttpRuntime.HostingInit(HostingEnvironmentFlags hostingFlags, PolicyLevel policyLevel, Exception appDomainCreationException) +336

[HttpException (0x80004005): Failed to map the path '/'.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11556592
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +141
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +4813333

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.225

UPDATE: I went back to the site a few minutes after posting this--made no changes to code or configuration--and the error went away. I'm really baffled, but it is no longer a problem.

Trevor
  • 13,085
  • 13
  • 76
  • 99
  • 1
    Thanks for the error message. There is either a problem with IIS or with your ASP.NET applications (betting this). You are going to need to post your code, tell us more about the problem. How many websites of yours are affected? What changes have you performed recently? When did the problem start? – rlb.usa Sep 08 '11 at 22:30
  • have you got anything in your web.config file or .asax files? – Christian Sep 08 '11 at 22:31
  • Did you modify the properties of your virtual directories or the IIS app pool? Have you tried restarting IIS? Are all of the appropriate files still present on the server? – rlb.usa Sep 08 '11 at 22:53
  • Same thing happened to me. I let it sit and came back and its fine. Keep the question up for reference. – Donny V. Dec 31 '19 at 18:45

21 Answers21

262

restarting IIS solved the same issue in my case. Seems like something fails in IIS. Didn't worth my panic, either.

IIS 7.5, btw.

keremispirli
  • 3,283
  • 2
  • 19
  • 26
  • 19
    open cmd prompt and run 'iisreset'. As prosaic as it sounds, it worked! – argyle Apr 30 '12 at 18:04
  • 11
    +1 Helped me. Was caused after I renamed the "Default Web Site" to another name. (Stoping and starting IIS in management console solved it.) – TN. Sep 01 '12 at 17:57
  • 1
    +1 Started after removing default site. Fixed with iisreset as suggested. – Mayo Oct 25 '12 at 20:10
  • Damn, such a nuisance. Really worth trying to restart, before verifying each and other config file, don't worth panic. – Johnny_D Oct 27 '13 at 19:48
140

I had the same issue (MVC 4) under IIS 7. It turned out that the App Pool identity didn't have the correct authorization to the site's path.

65

You don't have to reset IIS, you can just recycle the app pool.

Brandon Montgomery
  • 6,924
  • 3
  • 48
  • 71
  • This answer deserves more upvotes. A very slick solution. Why rebuild the whole tower if rebuilding just a room can work. – RBT Apr 13 '23 at 02:02
31

Today when I renamed the default website, under which my MVC application was hosted, I started getting that error too. But I restarted IIS and the issue was resolved.

Scott
  • 21,211
  • 8
  • 65
  • 72
Rahul Bagal
  • 411
  • 4
  • 3
  • 6
    I had exactly the same problem — I renamed the site within IIS and I started getting this error. Recycling the app pool made it go away (and restarting IIS would automatically recycle the app pools, of course). Most odd. – Owen Blacker Sep 20 '12 at 10:57
5

I also have same issue. In my case working on InstalledSheild / InstalledAware, to make setup of web service. After setup run the above error comes, while resolve issue when check, found that IIs default website path remove after setup run.

So I just add path as below step.

  1. Go to Command prompt -> type InetMgr
  2. Its open IIS, go to 'Default Web Site' -> Advanced Settings (at right side menu) enter image description here

  3. Go to Physical Path and paste this things - '%SystemDrive%\inetpub\wwwroot' as below enter image description here

Ajay2707
  • 5,690
  • 6
  • 40
  • 58
  • This solution worked for me where I was installing a site from a Windows Installer. My Physical Path setting was originally "C:\inetpub\wwwroot" which was the correct path, but after changing the value to "%SystemDrive%\Inetpub\wwwroot" the installer completed successfully. – David Baker Nov 29 '18 at 20:25
4

Just start cmd and run the command iisreset and error will be gone.

Anand Raj
  • 41
  • 1
  • 1
2

These samples run in server. So either the Windows user must have READ/WRITE permissions or must run the sample in Administrator mode.

Try running the sample in Administrator mode.

Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108
2

I found that I had misnamed some virtual directories in IIS Manager. After fixing them, I was good.

woodge
  • 91
  • 1
  • 4
2

The following works for me: 1. Right click on "Default web site" 2. Choose Advance settings 3. Setup Physical Path to C:\inetpub\wwwroot 4. Click OK. 5. Browse the Default web site. --> It works.

2

I had this issue with a specific application and not the entire IIS site. In my case, access to the application directory was not the problem. Instead, I needed to give the application pool a recycle.

I think this was related to how the application was deployed and the IIS settings were set (done via scripts and a deployment agent).

War Gravy
  • 1,543
  • 3
  • 20
  • 32
  • This was my issue as well. I had renamed the name of the site under the Sites list in the left panel of IIS and then the site stopped working until I recycled it's application pool. – RonC Jul 14 '23 at 15:12
1

I Think this is because of IIS is unable to find the root folder. i.e wwwroot. Restarting the IIS wont be helpful in some scenarios. if the root path has changed, you should bring it back to %SystemDrive%\inetpub\wwwroot

by right clicking sites node in IIS and changing physical path to the above one.

and make sure that your application pool is asp.net v4.0 and running in integrated mode

amesh
  • 1,311
  • 3
  • 21
  • 51
1

i have tried following solution and it had work for me C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe right click on Devenv.exe in Compablity tab --> Privilage Level --> click on Run this Program as an Adminstrator If as for the Admin Password Provide it

if it is already selected deselect it and again select it -->Apply-->OK

restart the VS application and Publish your website again

Vikas
  • 11
  • 1
1

I was receiving this error because I happened to be opening a website project over a mapped network drive z:\folder instead of connecting via a UNC path \\server\path\folder. Once I opened the project from the UNC path it built just fine.

Jerreck
  • 2,930
  • 3
  • 24
  • 42
1

I experienced this after updating to Windows 10 Fall Creators edition version 1709. None of the solutions above worked for me. I was able to fix the error this way:

  1. Go to “Control Panel” > “Administrative Tools” > “IIS Manager”.
  2. Choose “Change .NET Framework Version” from the “Actions” in the right margin.
  3. I chose the latest version shown and clicked “OK”.

If IIS Manager is not available under Administrative Tools, you can enable it this way:

  1. Press the Windows key and type "Turn Windows Features On or Off" then select the search result.
  2. In dialog that appears, check the box by “Internet Information Services” and click OK.
Tom B.
  • 11
  • 2
1

This line (top of the stack trace) is telling you there is something wrong which the hosting configuration.

 System.Web.HttpRuntime.HostingInit(HostingEnvironmentFlags hostingFlags, PolicyLevel policyLevel, Exception appDomainCreationException) +336

How is your server set up? Have you checked the config files?

I'd search through them specifically for any settings or attributes which have the single value "/".

m.edmondson
  • 30,382
  • 27
  • 123
  • 206
1

Changing pool from ASP.NET v4.0 to Framework4 worked for me.

Tom
  • 3,009
  • 1
  • 18
  • 23
0

~I've gone to the Internet Information Services Manager

~Click the sites

~Right click on your website

~Click Manage Website > Advance Settings

~Change the application pool to DefaultAppPool

And it works fine to me.

0

I ran into the same issue when trying to run the ASP.Net precompiler, it turned out that I was not opening the command prompt as administrator. Once I did, I was able to run the asp.net compiler successfully.

Stuart Smith
  • 1,931
  • 15
  • 26
0

My solution was to make sure that all IIS features are installed. So went to add remove programs in the control panel and clicked on add remove windows features and selected all options except IIS 6 console compatibility.

Bashir Momen
  • 1,461
  • 19
  • 17
0

It could be due to data in your web.config file. E.g. a backslash in a domain username.

userName='domain\user'. 
-1

Executing the command iisreset (cmd with elevated rights) fixed this issue for me.

Sebastian
  • 2,874
  • 25
  • 31
user
  • 19
  • 4