2014-03-24 48 views
1

我有一個應用程序ASP.Net,Web API與C#,使用HTTPS,我希望與HTTP發送的JS,CSS文件和圖像。 我嘗試不同的想法,但它沒有奏效。 我已經試過這樣:爲js和png文件重寫規則到web.config

<rewrite> 
    <rules> 
    <rule name="Redirect Image to HTTP"> 
     <match url=".*\.(gif|jpg|jpeg|png|css|js)$"/> 
     <action type="Redirect" url="http://{SERVER_NAME}/{R:1}" redirectType="SeeOther"/> 

    </rules> 
</rewrite> 

我在做什麼錯?

回答

0

試試這個

<rules> 
    <rule name="Redirect Image to HTTP"> 
     <match url=".*\.(gif|jpg|jpeg|png|css|js)$"/> 
     <action type="Redirect" url="http://{SERVER_NAME}/{R:1}" redirectType="Found"/> 

    </rules> 
+0

同樣的事情:頁面仍在加載,但我試圖通過HTTP發送的文件是'n .. – florinaL

0

也許你應該指定HTTPS作爲條件:

<rewrite> 
    <rules> 
    <rule name="Redirect Image to HTTP"> 
     <match url=".*\.(gif|jpg|jpeg|png|css|js)$"/> 
     <conditions> 
      <add input="{HTTPS}" pattern="ON" /> 
     </conditions> 
     <action type="Redirect" url="http://{SERVER_NAME}/{R:1}" redirectType="SeeOther"/> 
    </rules> 
</rewrite> 

BTW,最好在你的正則表達式使用.+而非.*

+0

也許它的工作,但頁面仍然正在加載.. loading .. loading ..約3分鐘...我嘗試使用http發送的圖像未加載到頁面中。 – florinaL

+0

您是否試圖通過直接鏈接加載圖片?結果是什麼? – Smileek

+0

我已經嘗試過了,事件如果圖像是http或https頁面不會停止加載...圖像are'n加載..我必須做什麼?什麼是錯的..所有這些都在本地機器上..不在服務器上。 – florinaL

相關問題