2014-07-02 27 views
0

我有一個解決方案與多個項目,變換工作在其他項目,但不是這一個。可能是什麼原因?web.config轉換在發佈時不起作用

該項目是一個MVC 4應用程序

該解決方案的配置管理器顯示,當溶液的配置是LIVE那麼就應該使用LIVE配置項目。

有一個Web.config,Web.Live.config,Web.Stage.config

在Web.Live.config我有這樣的代碼:

<?xml version="1.0" encoding="utf-8"?> 

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> 

    <system.web> 
    <compilation debug="false" xdt:Transform="SetAttributes"></compilation> 
    </system.web> 

    <system.webServer> 
    <rewrite> 
     <rules> 
     <clear /> 
     <rule name="Redirect to https" stopProcessing="true"> 
      <match url="(.*)" /> 
      <conditions> 
      <add input="{HTTPS}" pattern="off" ignoreCase="true" /> 
      </conditions> 
      <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" /> 
     </rule> 
     </rules> 
    </rewrite> 
    </system.webServer> 
</configuration> 

我將它發佈到我Web服務器,確保配置設置爲Live。

服務器上的Web配置不包含轉換。

任何想法?

回答

1

我已經解決了這個問題,看來在這種情況下,我不得不將xdt:Transform="Insert"添加到<rewrite>標記中。

我不知道爲什麼我需要這樣做,考慮到轉換後的配置文件的默認模板包含插入代碼的標記,但沒有這樣的屬性可以正常工作...