Error: Unable to load configuration file: Failed to map path '/'

Hello Experts,

My application was running fine till yesterday. I dont know what changes did i do. I am getting failed to map path '/' in some pages . I tried to google it , some of them say that you need to run Visual Studio as administrator which I am doing but the error is still there.

This is the code where it is generating error. I am trying to set password in my web.config file.

protected void Page_Load(object sender, EventArgs e)

{

config =
WebConfigurationManager.OpenWebConfiguration("~");

section = (AppSettingsSection)config.GetSection("appsettings");

System.Configuration.KeyValueConfigurationElement c = config.AppSettings.Settings["Password"];if (null != c)

{

TextBox2.Text = c.Value;

}

Regards,

Pradeep 

 

 

 

-1
pradeepkk2008
11/3/2008 3:06:35 PM
asp.net.config-deploy 12495 articles. 0 followers. Follow

3 Replies
5950 Views

Similar Articles

[PageSpeed] 32

Hi,

If your configuration file is in the root of your website, you can try to use "/YourWebSiteName" to replace "~". For example: WebConfigurationManager.OpenWebConfiguration("/YourWebSite");

Is your website IIS-Based or File System-Based? This configuration file should be in virtual path.

 

I look forward to hearing from you.


Thomas Sun
Microsoft Online Community Support

Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question.
0
Thomas
11/6/2008 9:28:38 AM

Hello Thomas,

I have tried the virtual path of my application which is /Corridor , but it gives me same error.

My web.config resides in C:/Project/CT6/Corridor/web.config. and my project location is C:/Project/CT6/Corridor

This is strange as same code was running before.now its giving error.

I guess this application is IIS based rather than file based. How do you check whether the application is IIS based or file based?

Looking forward to get this sorted as I have a demo to give

Thanks

Pradeep

0
pradeepkk2008
11/6/2008 11:24:00 AM

Hi,

Thanks for your response.

If website is File System-Based, it is using ASp.NET built-in server as Development server, instead of IIS. Its url should like http://localhost:portNo/websiteName/PageName.aspx.

You can try to put your website to "C:\Inetpub\wwwroot" (which is virtual directory by default), and then open it use Visual Studio by File->Open->Web Site->Click "Local IIS" from left, and then select your website.

 

I look forward to hearing from you.


Thomas Sun
Microsoft Online Community Support

Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question.
0
Thomas
11/7/2008 8:28:43 AM
Reply: