IIS 7.5 Wcf routing service. http header disappears

1.2k views Asked by At

I have set up a wcf routing service (IIS 7.5) to sit between my winforms clients and a back-end server.

I am trying to resolve a bug which is apparently caused by the disappearance of the http header 'Accept-Language'. The client sends this header in the request, but according to fiddler (and the behavior I am observing) the request going out of the iis does not have the 'Accept-Language' header. This causes the server to send back data formatted in en-US locale in stead of the locale specified by the client.

At this url, they give an example of how to do what I want. This is the config I have done based on that (I was doing url rewriting already). The serverVariables part is the bit that is supposed to address my issue:

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

The url rewriting works fine. My only remaining issue is the http header mangling. In IIS manager I have set up HTTP_ACCEPT_LANGUAGE as an allowed server variable within the url rewrite module. What am I missing?

1

There are 1 answers

0
LOAS On BEST ANSWER

Turns out the url rewriting wasn't the culprit. The Wcf routing taking place after the url rewriting was mangling my http headers.

To fix it I only had to change

<routing filterTableName="filterTable" />

to

<routing filterTableName="filterTable" soapProcessingEnabled="false" />

in the serviceBehavior

And presto - problem gone! That also means that I could remove the handling of http headers during url rewriting I had added to my config.

My CS professor hit it on the head when he said: "If you can't find the problem it's because it is somewhere else."