IIS 7 URL重写模块web.config部分c#
我们正在使用带有 asp.net C# 的 IIS7 URL 重写模块,所有 URL 均已配置并直接写入 web.config:
<system.webServer>
<!-- ... -->
<rewrite>
<rules>
<clear />
<rule name="Category URL" stopProcessing="true">
<match url="somepage.aspx" ignoreCase="false"/>
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{QUERY_STRING}" pattern="REDIRECTION=true"
ignoreCase="false"/>
<add input="{QUERY_STRING}" pattern="categoryid=([^&]*)"/>
</conditions>
<action type="Redirect" url="http://{HTTP_HOST}/browsing/categorylanding.aspx?navcategoryid={C:1}"/>
</rule>
</rules>
</rewrite>
</system.webServer>
我需要将其移至一个部分,以便我可以为 QA、DEV 和 Production 制定单独的规则,什么将是“我将在本节中定义的类型?
<configSections>
<section name="IISURLRewriteSection" type="???"/>
</configSections>
一旦从 web.config 移至另一个自定义配置文件,IIS 会自动选择这些设置吗?
We are using IIS7 URL rewrite module with asp.net C#, all of the URLs are configured and written directly into web.config:
<system.webServer>
<!-- ... -->
<rewrite>
<rules>
<clear />
<rule name="Category URL" stopProcessing="true">
<match url="somepage.aspx" ignoreCase="false"/>
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{QUERY_STRING}" pattern="REDIRECTION=true"
ignoreCase="false"/>
<add input="{QUERY_STRING}" pattern="categoryid=([^&]*)"/>
</conditions>
<action type="Redirect" url="http://{HTTP_HOST}/browsing/categorylanding.aspx?navcategoryid={C:1}"/>
</rule>
</rules>
</rewrite>
</system.webServer>
I need to move this to a section so that I can have seperate rules for QA, DEV and Production, what would be the "type that i would define in the section?
<configSections>
<section name="IISURLRewriteSection" type="???"/>
</configSections>
Will the IIS automatically pick up these settings once moved outside from web.config to another custom config file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我们求助于编写自己的 HTTPModule,因为从调试的角度来看,在 IIS 级别出现的任何问题都必须让运营团队参与 - 只需遵循我们组织中定义的流程:)
We resorted to writing our own HTTPModule since from debugging point of view as well any issues that would arise at IIS level would have to have the Operations team involved - just following a process defined in our org :)
恕我直言,最好的解决方案是将配置详细信息移至外部文件中,然后您可以根据环境进行交换。
使用将 IIS7 url 重写部分移出 web.config 文件中描述的方法非常容易,您可以在其中在您的
Web.config
文件中会有类似这样的内容:然后您可以将环境特定的内容存储在单独的文件
rewrite.config
中,如下所示:The best solution, imho, would be to move the configuration details into external files, which you can then swap out per-environment.
This is pretty easy to do using the method described in Moving IIS7 url rewrite section out of the web.config file, where you would have something like this in your
Web.config
file:Then you can store the environment specific stuff in a separate file,
rewrite.config
, looking something like this: