开发者

Interrupting POST request

开发者_如何学C

I'm working on ASP.NET file uploader and currently trying to resolve the following issue: Assume at some moment the server side HttpModule decides that incoming data stream is too long and must be aborted. So the code that would handle this situation at first glance would be very simple. Like this:

try {
  ...
  if (size >= maxSize)
    throw new InvalidOperationException("File is too large!");
}
catch (InvalidOperationException e) {
  HttpContext.Current.Response.Write(e.Message);
  HttpContext.Current.Response.End();
  return;
}

But unfortunately this does not work. Seems browser has not received the response and continues transferring data to server. Does anybody know why this does not work and how would be workaround?


Try calling Response.Close() instead. This will immediately close the socket connection. You may need to call Response.Flush() before hand.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜