失去了获得HTTP请求升级后到.NET Framework 4.5 [英] Lost access to HTTP Request after upgrade to .NET Framework 4.5

查看:254
本文介绍了失去了获得HTTP请求升级后到.NET Framework 4.5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个接受的jqGrid在HTML表单的形式POST请求,并返回JSON的WCF服务。

I have a WCF service that accepts a POST request from jqGrid in the form of HTML form and returns JSON.

虽然事情在.NET 4.0中,所有工作得很好。我可以通过要求[字段名] 访问服务中的表单字段。有一次,我升级到.NET 4.5,我所有的要求[字段名] 现在是空白。是否有某种已知的问题与.NET 4.5,WCF和 HttpContext.Current.Request

While things were on .NET 4.0, all worked fine. I could access form fields inside the service via request["fieldName"]. Once I upgraded to .NET 4.5, all my request["fieldName"] are now blank. Is there some kind of known issue with .NET 4.5, WCF and HttpContext.Current.Request?

下面是一个例子:

 POST http://{REMOVED}/Grid.svc/Execute HTTP/1.1
 Accept: application/json, text/javascript, */*; q=0.01
 X-Requested-With: XMLHttpRequest
 Content-Type: application/x-www-form-urlencoded; charset=UTF-8
 Accept-Encoding: gzip, deflate

 _search=false&nd=1355782305975&rows=15&page=1&sidx=modified&sord=desc&search=&category=all

和,这里是服务:

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class GridAccess
{
    [OperationContract]
    [WebInvoke(Method = "POST",
           BodyStyle = WebMessageBodyStyle.Bare,
           ResponseFormat = WebMessageFormat.Json,
           RequestFormat = WebMessageFormat.Json
    )]
    public GridResponse Execute()
    {
        var request = System.Web.HttpContext.Current.Request;

要求[字段名] 工作之前根据.NET 4.0和现在,升级到.NET 4.5之后,他们返回空值。

All references to request["fieldName"] worked before under .NET 4.0 and now, after upgrade to .NET 4.5, they return NULLs.

推荐答案

问题的根本原因看起来是一样的岗位描述的问题:<一href=\"http://stackoverflow.com/questions/12391586/visual-studio-2012-install-broke-my-2010-wcf-project\">Visual Studio 2012中安装打破了我2010 WCF项目。我可以看到,如果我按照工作在这个岗位周围建议您code重新开始工作。你可以参考<一个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-htt$p$pquest-getbufferlessinputstream-has-been-invoked.aspx\"相对=nofollow>这个的博客文章以了解更多信息。

The issue's root cause looks to be the same as the issue described in post : Visual Studio 2012 install broke my 2010 WCF project. I can see your code starts working again if I follow the work around suggested in this post. You can refer to this blog post for more information.

这篇关于失去了获得HTTP请求升级后到.NET Framework 4.5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆