How to access system.webserver web.config node in .NET 2
Are there any .NET APis that can read/update the system.webServer开发者_如何学Go node in web.config? I know I can do it via reading/parsing the web.config file as xml but that's awkward.
To read/update the system.web node in .NET 2 I can use:
HttpModulesSection httpModulesSection = (HttpModulesSection)configuration.GetSection("system.web/httpModules");
But is there any API based way of accessing system.web/modules using .NET 2?
I have to reference the .NET 2 version of system.web.configuration because I don't know in advance if my web app will be run on a server with .NET 2 or 3.5. So it is limited to .NET 2 API calls only.
Thanks
You need to use the Microsoft.Web.Administration.dll
assembly. You can check this blog post.
精彩评论