我已經設置了一個wcf路由服務(IIS 7.5),以便位於我的winforms客戶端和後端服務器之間。IIS 7.5 Wcf路由服務。 http標題消失
我想解決一個顯然是由http頭部'Accept-Language'消失引起的錯誤。客戶端在請求中發送這個頭,但根據fiddler(以及我觀察到的行爲),從iis發出的請求沒有「Accept-Language」頭。這會導致服務器發回以en-US語言環境格式化的數據,而不是客戶端指定的區域設置。
在this url,他們舉了一個如何做我想做的例子。這是我基於此做的配置(我正在進行url重寫)。 serverVariables部分是應該解決我的問題的位:
<system.webServer>
<!-- These url rewrite rules require the presence of the URL Rewrite 2.0 iis extension -->
<rewrite>
<rules>
<!-- Accept connections to service1.asmx by rewriting that part of the url to WcfRouter.svc/service1 -->
<rule name="service1Rule" stopProcessing="true">
<match url="^(.*)svc/service1.asmx" />
<serverVariables>
<set name="HTTP_ACCEPT_LANGUAGE" value="da-DK" />
</serverVariables>
<action type="Rewrite" url="{R:1}WcfRouter.svc/service1" />
</rule>
<!-- Ditto for service2.asmx -->
<rule name="service2Rule" stopProcessing="true">
<match url="^(.*)svc/service2.asmx" />
<serverVariables>
<set name="HTTP_ACCEPT_LANGUAGE" value="da-DK" />
</serverVariables>
<action type="Rewrite" url="{R:1}WcfRouter.svc/service2" />
</rule>
</rules>
</rewrite>
</system.webServer>
url重寫工作正常。我唯一剩下的問題是http頭部損壞。在IIS管理器中,我已經將URL_ACCEPT_LANGUAGE設置爲url重寫模塊中允許的服務器變量。我錯過了什麼?
我懷疑我迄今爲止所做的只是解決了在wcf路由發生之前發生的url重寫問題。所以我可能仍然需要解決wcf路由如何處理(或錯誤處理)我的http頭。這可以在配置中設置,或者我需要C#嗎? – LOAS 2012-08-17 09:57:00