100K大小的POST请求无法到达webAPI? [英] 100K sized POST requests don't get to webAPI?

查看:230
本文介绍了100K大小的POST请求无法到达webAPI?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Fiddler(或帖子管理器)来调用对WebApi的请求. (它作为IIS中的ASP.net应用程序托管)

这是服务:

    [HttpPost]
    [ActionName("uploadRessources")]
    [AllowAnonymous]
    public HttpResponseMessage uploadRessources(ResourcesJson json)
    {
      ...
        return Request.CreateResponse(HttpStatusCode.OK, result);
    }

对于短长度正文(3行数据)长度的数据发布请求,例如:

POST http://something.com/api/services/uploadRessources HTTP/1.1
Cache-Control: no-cache
Connection: keep-alive
Pragma: no-cache
Accept: application/json
Accept-Encoding: gzip
Accept-Language: he-IL
User-Agent: Mozilla/5.0
Content-Length: 451
Content-Type: application/json
Host: es.com

{ "l":
[{"MasterEntity":2,"screen":"ConfirmHealthDetailsPage","Lbl":"ApproveTheFollowingDetails","enus":"Approve the Following Details:","device":"mobile","description":"NULL"},
{"MasterEntity":2,"screen":"ConfirmHealthDetailsPage","Lbl":"PersonalDetails","enus":"Personal Details","device":"mobile","description":"NULL"},
{"MasterEntity":2,"screen":"FingerPrintResources","Lbl":"CANCEL","enus":"CANCEL","device":"mobile","description":"NULL"}]
 }

我确实获得了成功的答复:

HTTP/1.1 200 OK

但是对于较长的身体长度请求(101K)-

它被卡住了(它甚至没有在我的代码中达到断点,而在简短的请求中-确实发生了),而且我从没看到响应:

顺便说一句-如果稍后我再次运行短体长请求(同时仍在等待先前的大请求)-我得到200(短体请求).

在web.config中,我确实设置了:

<httpRuntime enableVersionHeader="false" executionTimeout="100000000" maxRequestLength="999999999" />

在IIS中:没有请求过滤器
在事件查看器中-我看不到任何异常或警告 IIS版本:6.1(Windows 7)-但它也发生在我们的服务器上.

问题

为什么我的101k长度不要求-访问我的webapi?

修改

我发现它发生在> 65k请求中.还是不知道是什么问题

解决方案

它卡在request.Content.ReadAsStringAsync().Result上(从未发布).奇怪但将其设置为async,解决了该问题.我仍然不知道为什么. 通常,这是解决方案 -左窗格是有问题的一是右窗格是工作窗格. (我必须说,左窗格曾经可以工作,但是升级到4.6.2之后-它开始出现问题)-再次-我不知道为什么

I'm using Fiddler (or post manager) to invoke requests to my WebApi. ( it's hosted as an ASP.net application in IIS)

This is the service :

    [HttpPost]
    [ActionName("uploadRessources")]
    [AllowAnonymous]
    public HttpResponseMessage uploadRessources(ResourcesJson json)
    {
      ...
        return Request.CreateResponse(HttpStatusCode.OK, result);
    }

For short length body( 3 rows of data) length post data requests like :

POST http://something.com/api/services/uploadRessources HTTP/1.1
Cache-Control: no-cache
Connection: keep-alive
Pragma: no-cache
Accept: application/json
Accept-Encoding: gzip
Accept-Language: he-IL
User-Agent: Mozilla/5.0
Content-Length: 451
Content-Type: application/json
Host: es.com

{ "l":
[{"MasterEntity":2,"screen":"ConfirmHealthDetailsPage","Lbl":"ApproveTheFollowingDetails","enus":"Approve the Following Details:","device":"mobile","description":"NULL"},
{"MasterEntity":2,"screen":"ConfirmHealthDetailsPage","Lbl":"PersonalDetails","enus":"Personal Details","device":"mobile","description":"NULL"},
{"MasterEntity":2,"screen":"FingerPrintResources","Lbl":"CANCEL","enus":"CANCEL","device":"mobile","description":"NULL"}]
 }

I DO get a successful response :

HTTP/1.1 200 OK

But for a long body length request ( 101K ) -

It is stuck (it even doesn't hit the breakpoint in my code , while in short request - it does )and I never see a response :

BTW - If later I do run again the short body length request( while still waiting for the previous large requests) - I do get 200 ( for the short length request).

In web.config I did set :

<httpRuntime enableVersionHeader="false" executionTimeout="100000000" maxRequestLength="999999999" />

In IIS : No requests filters
In Event Viewer - I don't see any exceptions or warnings IIS version : 6.1 ( windows 7) - but it also happens at our server.

Question

Why doesn't my 101k length request - get to my webapi ?

Edit

I've found that it happens for >65k requests. Still don't know what is the problem

解决方案

It was stuck on request.Content.ReadAsStringAsync().Result ( and never released). Strange but setting it to async , solved the problem. I still don't know why. In General this is the solution - the left pane was the problematic one while the right pane is the working one. ( I must say that the left pane used to work , but after upgrading to 4.6.2 - it started doing problems) - Again - I don't know why

这篇关于100K大小的POST请求无法到达webAPI?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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