我有一个 ASP.NET WebAPI 应用程序,一些请求超过了最大长度。没关系,I know I can increase the limit either in IIS or web.config ,但这不是我的意思。
当我使用 Request.Content.Read
方法之一读取请求的内容时,所有这些方法都返回一个 Maximum request length exceeded
异常。
不过,出于记录目的,我想检索正文的前几个字符。
是否仍然可以只读取正文的前几个字符?还是无法检索全部内容?
最佳答案
您必须在 global.asax 文件中捕获异常,然后您将获得请求数据。
查看这两个链接:
Catching "Maximum request length exceeded" http://geekswithblogs.net/sglima/archive/2011/09/20/how-to-handle-maximum-request-length-exceeded-exception.aspx
关于c# - 当 "Maximum request length exceeded"时读取主体的第一个字节,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41892301/