Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable Expect:100-Continue when using WCF in Windows Store App

Tags:

c#

wcf

I need to get rid of the Expect: 100-Continue header in HTTP message, when communicating with WebService using WCF in Windows Store App. I have found a lot of solutions, but none of them is possible in Windows 8:

  1. ServicePoint.Expect100Continue = false; doesn't exist in Store App any more (No SericePoint or ServicePointManager class),
  2. I cannot change configuration in web.config file, because it doesn't exist in Store App,
  3. It is possible to change the flag in HttpClient, but I cannot access it, when using WCF,
  4. I tried to manipulate with message headers using IClientMessageInspector, but the default HTTP headers are being added later, in higher layers, so my changes will be ovverriden.

Does anyone have any other ideas?

like image 967
Laurer Avatar asked Feb 28 '14 08:02

Laurer


1 Answers

There are 2 ways to deal with this.

You can turn set expect100Continue="false" in you app.config or web.config, but this will be global. This could be an issue if some external services prefer to use the header expect100Continue. Here's how:

<system.net>
     <settings>
        <servicePointManager expect100Continue="false"/>  
     </settings>
</system.net>

Or you can do it in code for a specific endpoint as follows:

System.Net.ServicePoint servicePoint =
     System.Net.ServicePointManager.FindServicePoint(myWcfService.Endpoint.Address.Uri);
servicePoint.Expect100Continue = false;
// now execute some service operation 
like image 124
AntonK Avatar answered Sep 30 '22 18:09

AntonK