请求参数不会在POST请求中传输

use*_*183 5 .net c# wcf post webmethod

我调用了一个WebMethod通过Fiddler,我在"请求体"中提供了2个需要的参数,我得到一个奇怪的行为:

  • 前10个请求,它按预期工作=>我可以找到参数值 HttpContext.Current.Request.Form
  • 从第11个POST请求开始,WCF在调试时WebMethod,POST参数不会传输到service => ,HttpContext.Current.Request.Form为空.

任何线索为什么会这样?

这是我的代码:

[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "/getsomething")]
[FaultContract(typeof(ResponseMessageStatus))]
[DynamicResponseType]
public Stream GetSomething()
{
    var par1 = HttpContext.Current.Request.Form["myparameter"] ;
    //after 10 requests, HttpContext.Current.Request.Form is empty.
    ...
}
Run Code Online (Sandbox Code Playgroud)

Jur*_*uri 0

此处可能有典型的 IIS 默认 10 个并发连接。从 fiddler 调用 WCF 方法后,您是否能够验证连接是否已关闭?可能它没有关闭,当你点击第 11 个请求时,它会挂起(直到池中的任何连接关闭),所以你看不到你的数据......

解决方案: 1.close 连接(自己制作代理测试客户端,调用后在代理上关闭连接)

var apiClient = CreateApiClient();
try
{
    apiClient.GetSomething();
    apiClient.Close();
}
catch (Exception ex)
{
    LogHelper.Current.WriteToLog(LogHelper.LogFiles.MessageLog, ex);
    apiClient.Abort();
}
Run Code Online (Sandbox Code Playgroud)

2.更改配置设置:

serviceThrottling maxConcurrentCalls="10000" maxConcurrentSessions="10000" maxConcurrentInstances="10000"
Run Code Online (Sandbox Code Playgroud)