Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>Note :</strong> This issue has been fixed in .net 4.5.1. You can see the fix with 4.5.1. Once you have .net 4.5.1 add the following appSetting to switch back to the old behavior. </p> <pre><code>&lt;configuration&gt; &lt;appSettings&gt; &lt;add key="wcf:serviceHostingEnvironment:useClassicReadEntityBodyMode" value="true" /&gt; &lt;/appSettings&gt; &lt;/configuration&gt; </code></pre> <p>Here is how you can create a HttpModule to force ReadEntityBodyMode to be "classic" : <a href="http://blogs.msdn.com/b/praburaj/archive/2012/09/13/accessing-httpcontext-current-request-inputstream-property-in-aspnetcompatibility-mode-throws-exception-this-method-or-property-is-not-supported-after-httprequest-getbufferlessinputstream-has-been-invoked.aspx" rel="noreferrer">http://blogs.msdn.com/b/praburaj/archive/2012/09/13/accessing-httpcontext-current-request-inputstream-property-in-aspnetcompatibility-mode-throws-exception-this-method-or-property-is-not-supported-after-httprequest-getbufferlessinputstream-has-been-invoked.aspx</a></p> <p>To answer your other question (Why are these Framework 4.5 properties are effecting my 4.0 solution?): .net 4.5 is an in-place upgrade of .net 4.0. So even if your project is targeting 4.0, since VS 2012 installs 4.5 runtime, some of the 4.5 behaviors take effect. </p> <p><strong>EDIT</strong></p> <p><em>Blog Entry:</em></p> <p>In .net 4.5 WCF leveraged the buffer less input stream for scalability benefits. As a result when you try to access the HttpContext.Current.Request.InputStream property you may end up with the below exception, as the InputStream property tries to get you handle to the Classic stream as they both are incompatible.</p> <blockquote> <p>“This method or property is not supported after <strong>HttpRequest.GetBufferlessInputStream</strong> has been invoked.”</p> </blockquote> <p>If you had a WCF 4.0 app which worked perfectly but on upgrading your .net framework to 4.5 you notice the service failing on accessing this property, here is the way to work-around the issue:</p> <ul> <li><p>Add a simple HttpModule in the same WCF project which will access the InputStream property for each request before WCF reads it so that it will enforce the HttpContext.Request.ReadEntityBody to be "Classic" and will ensure compatibility. </p> <pre><code>public class WcfReadEntityBodyModeWorkaroundModule : IHttpModule { public void Dispose() { } public void Init(HttpApplication context) { context.BeginRequest += context_BeginRequest; } void context_BeginRequest(object sender, EventArgs e) { //This will force the HttpContext.Request.ReadEntityBody to be "Classic" and will ensure compatibility.. Stream stream = (sender as HttpApplication).Request.InputStream; } } </code></pre></li> <li><p>Register this module in your web.config by adding these lines in <code>&lt;configuration&gt;</code> <code>&lt;modules&gt;</code> setting. </p> <pre><code>&lt;system.webServer&gt; &lt;modules&gt; &lt;!-- Register the managed module --&gt; &lt;add name="WcfReadEntityBodyModeWorkaroundModule" type="MyAssembly.WcfReadEntityBodyModeWorkaroundModule, MyAssembly" /&gt; &lt;/modules&gt; </code></pre></li> <li><p>If you are using an app pool in classic mode, you will need to add the module to this section in the web.config:</p> <pre><code>&lt;system.web&gt; &lt;httpModules&gt; &lt;add name="WcfReadEntityBodyModeWorkaroundModule" type="MyAssembly.WcfReadEntityBodyModeWorkaroundModule, MyAssembly" /&gt; &lt;/httpModules&gt; </code></pre></li> </ul> <p>If your project cannot be modified, then you can write this Http module in a separate assembly, GAC it separately and register this module in the web.config.</p> <p>Now try accessing the service it should succeed for you!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload