2011-10-14 45 views
0

我們正在使用IIS7 URL重寫模塊asp.net C#中,所有的URL的配置和直接寫入web.config中:IIS 7 URL重寫模塊web.config部分,C#

<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> 

請問IIS後自動拾取這些設置從web.config移出到另一個自定義配置文件?

回答

0

我們採取了從調試的觀點以及將出現在IIS級別的任何問題編寫我們自己的HttpModule,因爲必須具有所涉及的運營團隊 - 只要按照我們的組織:)

0
定義的過程

最好的解決方案,恕我直言,將配置的詳細信息轉移到外部文件,然後您可以換出每個環境。

這是很容易使用Moving IIS7 url rewrite section out of the web.config file,所描述的方法去做,你就會有這樣的事情在你的Web.config文件:

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

然後你就可以將環境具體的東西存儲在一個單獨的文件,rewrite.config ,看起來像這樣:

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