Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ASP:NET 411-所需内容长度错误_C#_Asp.net - Fatal编程技术网

C# ASP:NET 411-所需内容长度错误

C# ASP:NET 411-所需内容长度错误,c#,asp.net,C#,Asp.net,关于平均411错误,有一些问题和答案。 但我的有点奇怪:我们有一个测试服务器,而且效率很高。我描述的错误发生在testserver上,它的代码与produtive完全相同(除了连接字符串)。 我们正在代码隐藏中调用WebMethod: [WebMethod] public static object GetEnterEditModeObject() { object btnId = HttpContext.Current.Session[Constants

关于平均411错误,有一些问题和答案。 但我的有点奇怪:我们有一个测试服务器,而且效率很高。我描述的错误发生在testserver上,它的代码与produtive完全相同(除了连接字符串)。 我们正在代码隐藏中调用WebMethod:

    [WebMethod]
    public static object GetEnterEditModeObject()
    {
        object btnId = HttpContext.Current.Session[Constants.Session.RoleEditBtnClientId.ToString()];
        var indRole = (V_WFA_ROLES)HttpContext.Current.Session[Constants.Session.RoleCurrentDatarow.ToString()];

        if (btnId != null && indRole != null)
        {
      ///... Some more code here

            var result = new
                {
                    btnId,
                    ///More Variables here

                };

            HttpContext.Current.Session[Constants.Session.RoleCurrentDatarow.ToString()] = null;
            HttpContext.Current.Session[Constants.Session.RoleEditBtnClientId.ToString()] = null;

            return result;
        }

        return null;
    }
这里没什么好想象的:我们从会话中读取两个值,如果它们存在,我们创建一个新对象,清除会话并返回对象,否则我们只返回null

这在很长一段时间内运行良好,但现在我们得到了我上面提到的错误。 由于它仍在生产中,我可以很容易地处理它,我得到以下两个标题:

HTTP/1.1 411 Length Required
Date: Mon, 24 Feb 2014 13:10:40 GMT
Server: Apache
Content-Length: 344
X-FRAME-OPTIONS: SAMEORIGIN
Connection: close
Content-Type: text/html; charset=us-ascii


HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json; charset=utf-8
Expires: -1
Server: Microsoft-IIS/7.5
X-UA-Compatible: IE=9; IE=8
Date: Mon, 24 Feb 2014 13:12:22 GMT
Content-Length: 10
Via: SomeURL
正如您所看到的,两个标题的内容长度都存在,但我仍然得到这个错误

你能给我一些提示吗?是什么引起了这样的问题?代码中是否有可能会导致这种伤害的错误?如果是,简单的try/catch是否可以解决此问题

感谢所有回复,本周有一个良好的开端

马蒂亚斯

编辑:通过添加

 [ScriptMethod(UseHttpGet=true, ResponseFormat = ResponseFormat.Json)]
对于所有的Webmethods,现在,我得到以下信息

HTTP/1.1 303 See Other
Date: Mon, 24 Feb 2014 17:04:33 GMT
Server: Apache
Content-Length: 196
Location: /error_path/400.html?al_req_id=Uwt7oX8AAAEAAGijHI4AAAYG
X-FRAME-OPTIONS: SAMEORIGIN
Keep-Alive: timeout=10, max=500
Connection: Keep-Alive
Content-Type: text/html
它似乎将页面移动到错误路径,但在Fiddler中不会显示任何错误,JavaScript也不会导致问题

这种行为似乎是需要的,但正如所说,代码与生产中的代码相同,在生产中不会发生这种情况

这是IIS设置吗?这会给我带来麻烦吗


Edith2:明白了,testsystem上安装了一个新的防火墙组件,它检查并更改了请求头。因此,我们了解到:如果标题不同,则系统上存在差异,客户是错误的

Matthias,你能和我联系吗(电子邮件:mnot@mnot.net,或在推特上@mnot)?我正在研究一个互操作性问题,这似乎与您提到的防火墙有关。谢谢