I’m using following code to open the web.config of my current web application.
Configuration rootConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/MyAppRoot");
But it only works on my development machine, not production machine. Shall I use something else other than “/MyAppRoot”?
Thanks in advance!
Thank you for your answer, Matthew! I really appreciate it! But I finally found that problem occurs because my application did not run under default site name. The problem was solved by passing httpContext.Request.ApplicationPath rather than “/MyAppRoot” to the OpenWebConfiguration method.