2013-05-02 10 views
5

web.configデプロイメント変換を書き換えルールで使用する方法を理解できません。私は次のことを試してみて、それを無視します。vs2012 WebデプロイメントWeb.config変換でURL書き換えルールを更新する

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


<system.webServer> 
<rewrite xdt:Transform="Replace"> 
    <rules> 

    <rule name="Force HTTPS On Login/Register" stopProcessing="true"> 
     <match url="Account/Login(.*)|Register(.*)" ignoreCase="true" /> 
     <conditions> 
     <add input="{HTTPS}" pattern="^OFF$" /> 
     </conditions> 
     <action type="Redirect" url="https://{HTTP_HOST}/{R:0}" redirectType="Permanent" /> 
    </rule> 


    <rule name="Force HTTPS Off" stopProcessing="true"> 
     <match url="((Account/Login(.*))|(Register(.*)))" negate="true" ignoreCase="true" /> 
     <conditions> 
     <add input="{HTTPS}" pattern="^ON$" ignoreCase="true" /> 
     </conditions> 
     <action type="Redirect" url="http://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" /> 
    </rule> 


    </rules> 
</rewrite> 
</system.webServer> 
+0

あなたが提案したとおりに機能しました。これまで私はslowcheetahを使用する必要はありませんでした。私はそれについて聞いていますが、私の依存関係を維持し続けるのは嫌です。 –

答えて

6

私は、生産のために私のweb.configを変換するためにSlowCheetahを使用します。私はもともとそれがある(あなたがしようとしたものを試してみましたが、私は基本web.configファイルに

を空

<rewrite> 
    <rules /> 
</rewrite> 

を追加し

<system.webServer> 
    <rewrite> 
     <rules> 
     <rule name="Redirect to HTTPS" stopProcessing="true" xdt:Transform="Insert"> 
      <match url="(.*)" /> 
      <conditions> 
      <add input="{HTTPS}" pattern="^OFF$" /> 
      </conditions> 
      <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" /> 
     </rule> 
     </rules> 
    </rewrite> 
</system.webServer> 

のような変換を書かなければならなかったことがわかりましたリダイレクト変換、しかし私は同じプリンシパルが適用されるべきだと思う)。

xdt:Transform="Insert"基本設定ファイルの骨格<rules />に新しいノードを挿入します。

+0

こんにちはEric、空のルールでhttp:// 500.19エラーが発生する問題を見たことがありますか?私の紺碧のVMは、そのエラーをスローしますが、私のコロサーバー(同じOS)はしません。 –

+0

いいえ私はAzureを使用していませんが、私はその状況を見ていません。おそらくAzureに固有のエラーに関する新しい質問を投稿しますか?そのエラーは、設定ファイルが無効であることを意味します。変換がAzure VMに正しく適用されていますか? http://blogs.msdn.com/b/webtopics/archive/2010/03/08/troubleshooting-http-500-19-errors-in-iis-7.aspx –

関連する問題