Home > Uncategorized > Failed to map path ‘/’

Failed to map path ‘/’

Have you ever seen this problem? It looks a bit like this…

Well you might if you are working on Vista, Windows 7 or Windows 2008. In this case I’m on Windows 2008. The simple workaround is to run Visual Studio as an administrator, but this is bad and what if it occurs in production and not just during development?

Well the guys at Microsoft have the answer…

Calling OpenWebConfiguration(null) means that code wants to open the root web.config file for *both* read and write access. The default file-system ACLs on the root web.config file only grants write access to administrators. The "Users" group has read access. The root web.config file is locked down to only grant write access to administrators because configuration changes to this file affect every web application on a machine.

Applications that intend to only edit configuration information for a specific application should call one of the OpenWebConfiguration overloads that accept a specific path and a web site name. This will cause the configuration system to request write access for an application-specific web.config file, as opposed to the global root web.config file. – Microsoft Connect (https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=358766)

There you go, the cause of the problem is how the web.config is being opened. In most cases you only want to open it for READING, not for writing… so how can you do that?

Forget the WebConfigurationManager.OpenWebConfiguration() methods. Use the WebConfiguration.GetSection() method instead. This will get the configuration from the currently executing ASP.NET application.

 

 

 

Advertisements
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: