API for IIS7 Rewrite Section
Is there an API that I just can't find under system.webserver for the rewrite sec开发者_JAVA技巧tion, or perhaps under Microsoft.Web.Administration with a strongly typed Rewrite class? I'd rather not have to write that class by hand, since I assume it's already there somewhere for use by IIS.
Because the URL Rewrite module is an IIS extension there aren't "strongly typed" classes built into the Microsoft.Web.Administration
namespace to do this. i.e. there isn't a class called Microsoft.Web.Administration.UrlRewrite
.
However, you can work with the built-in ConfigurationSection
, ConfigurationElementCollection
and ConfigurationElement
classes to manipulate the <rewrite>
section of your web.config
.
One of the IIS Program Managers has a blog entry about programmatically configuring the URL Rewrite Module:
Scripting URL rewrite module configuration
That should get you started.
精彩评论