簡體   English   中英

IIS 7 URL重寫模塊web.config部分C#

[英]IIS 7 URL rewrite module web.config section 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=([^&amp;]*)"/>
                </conditions>
                <action type="Redirect" url="http://{HTTP_HOST}/browsing/categorylanding.aspx?navcategoryid={C:1}"/>
            </rule>
        </rules>
    </rewrite>
 </system.webServer>

我需要將其移至某個部分,以便為QA,DEV和生產制定單獨的規則,在該部分中定義的“類型”是什么?

<configSections>
    <section name="IISURLRewriteSection" type="???"/>
</configSections>

從web.config移到另一個自定義配置文件后,IIS是否會自動選擇這些設置?

最好的解決方案,恕我直言,是將配置詳細信息移到外部文件中,然后您可以根據環境交換出去。

使用將IIS7 URL重寫部分從Web.config文件移出所述的方法,這很容易做到,在Web.config文件中將具有以下內容:

<system.webServer>
    <rewrite configSource="rewrite.config"/>
</system.webServer>

然后,您可以將特定於環境的內容存儲在單獨的文件rewrite.config ,如下所示:

<rewrite>
    <rules>
        <clear />
        <rule name="Category URL" stopProcessing="true">
            <!-- ... --->
        </rule>
    </rules>
</rewrite>

我們之所以要編寫自己的HTTPModule,是因為從調試的角度出發,以及在IIS級別出現的任何問題都必須讓操作團隊參與其中-僅遵循我們組織中定義的過程即可:)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM