捕获“超出最大请求长度”的异常 [英] Catching Exception for "Maximum request length exceeded"
问题描述
问候,
我有一个ASP.NET页面,它接受来自HtmlInputFile对象的输入。
我设置了最大大小对于web.config文件中的HttpRequests为2MB。
现在我试图捕获超出最大请求长度
当用户遇到HttpException尝试发送一个大于2MB的文件,所以我可以优雅地告诉用户他们的文件太大了。
现在,我的问题是世界上我在哪里为HttpException添加一个处理程序,
显然我不够聪明,不知道这里发生了什么或找到任何一种
有用关于这个问题的文章(我找到的所有文章,都没有解决我想要做的事情,更糟糕但是没有给出任何真正明确的例子
只是模糊的描述)。
谢谢,
克里斯
我想通了......
我把代码放在
global.asax文件的Application_Error方法中处理它...我现在倾向于忽略global.asax ......
Chris
" Chris Hayes" < cp.hayes @ [NO2SPAM] sbcglobal.net>在消息中写道
news:u5 ************** @ TK2MSFTNGP10.phx.gbl ...问候,>
我有一个ASP.NET页面,它接受来自HtmlInputFile对象的输入。
我已经在web.config
文件中将HttpRequests的最大大小设置为2MB。 br />
现在我试图捕获超出最大请求长度
当用户尝试发送大于2MB的文件时HttpException
我可以告诉用户,优雅地说,他们的文件太大。
现在,我的问题是在世界上我为HttpException添加一个处理程序,显然我不够聪明,不知道在这里找到或者找到任何有用的文章(我发现的所有文章,都没有解决我想要做的事情,更糟糕但是没有给出任何
真实的例子只是模糊的描述。
谢谢,
Chris
我把代码放在
global.asax文件的Application_Error方法中来处理...我现在往往会忽视global.asax ......
Chris
" Chris Hayes" < cp.hayes @ [NO2SPAM] sbcglobal.net>在消息中写道
news:u5 ************** @ TK2MSFTNGP10.phx.gbl ...
问候,>
我有一个ASP.NET页面,它接受来自HtmlInputFile对象的输入。
我已经在web.config
文件中将HttpRequests的最大大小设置为2MB。 br />
现在我试图捕获超出最大请求长度
当用户尝试发送大于2MB的文件时HttpException
我可以告诉用户,优雅地说,他们的文件太大。
现在,我的问题是在世界上我为HttpException添加一个处理程序,显然我不够聪明,不知道在这里找到或者找到任何有用的文章(我发现的所有文章,都没有解决我想要做的事情,更糟糕但是没有给出任何
真实的例子只是模糊的描述。
谢谢,
Chris
Chris
" Chris Hayes" < cp.hayes @ [NO2SPAM] sbcglobal.net>在消息中写道
news:u5 ************** @ TK2MSFTNGP10.phx.gbl ...
问候,>
我有一个ASP.NET页面,它接受来自HtmlInputFile对象的输入。
我已经在web.config
文件中将HttpRequests的最大大小设置为2MB。 br />
现在我试图捕获超出最大请求长度
当用户尝试发送大于2MB的文件时HttpException
我可以告诉用户,优雅地说,他们的文件太大。
现在,我的问题是在世界上我为HttpException添加一个处理程序,显然我不够聪明,不知道在这里找到或者找到任何有用的文章(我发现的所有文章,都没有解决我想要做的事情,更糟糕但是没有给出任何
真实的例子只是模糊的描述。
谢谢,
Chris
Greetings,
I have an ASP.NET page that accepts input from an HtmlInputFile object.
I have set the maximum size for HttpRequests to 2MB in the web.config file.
And now I am trying to CATCH the "Maximum request length exceeded"
HttpException when a user tries to send a file that is greater than 2MB so
that I may tell the user, gracefully, that their file is too big.
Now, my question is where in the world do I add a Handler for HttpException,
apparrently I''m not smart enough to know where this goes or to find any kind
of useful article on the subject (all the ones I have found, don''t address
what I am trying to do, and worse yet don''t give any real clear examples
just vague descriptions).
Thanks,
Chris
I figured it out...
I placed the code to handle it in the Application_Error method of the
global.asax file... I tend to overlook the global.asax nowadays...
Chris
"Chris Hayes" <cp.hayes@[NO2SPAM]sbcglobal.net> wrote in message
news:u5**************@TK2MSFTNGP10.phx.gbl...Greetings,
I have an ASP.NET page that accepts input from an HtmlInputFile object.
I have set the maximum size for HttpRequests to 2MB in the web.config
file.
And now I am trying to CATCH the "Maximum request length exceeded"
HttpException when a user tries to send a file that is greater than 2MB so
that I may tell the user, gracefully, that their file is too big.
Now, my question is where in the world do I add a Handler for
HttpException, apparrently I''m not smart enough to know where this goes or
to find any kind of useful article on the subject (all the ones I have
found, don''t address what I am trying to do, and worse yet don''t give any
real clear examples just vague descriptions).
Thanks,
Chris
I figured it out...
I placed the code to handle it in the Application_Error method of the
global.asax file... I tend to overlook the global.asax nowadays...
Chris
"Chris Hayes" <cp.hayes@[NO2SPAM]sbcglobal.net> wrote in message
news:u5**************@TK2MSFTNGP10.phx.gbl...Greetings,
I have an ASP.NET page that accepts input from an HtmlInputFile object.
I have set the maximum size for HttpRequests to 2MB in the web.config
file.
And now I am trying to CATCH the "Maximum request length exceeded"
HttpException when a user tries to send a file that is greater than 2MB so
that I may tell the user, gracefully, that their file is too big.
Now, my question is where in the world do I add a Handler for
HttpException, apparrently I''m not smart enough to know where this goes or
to find any kind of useful article on the subject (all the ones I have
found, don''t address what I am trying to do, and worse yet don''t give any
real clear examples just vague descriptions).
Thanks,
Chris
Anyone have any other ideas? Because I am out of ideas now.
Chris
"Chris Hayes" <cp.hayes@[NO2SPAM]sbcglobal.net> wrote in message
news:u5**************@TK2MSFTNGP10.phx.gbl...Greetings,
I have an ASP.NET page that accepts input from an HtmlInputFile object.
I have set the maximum size for HttpRequests to 2MB in the web.config
file.
And now I am trying to CATCH the "Maximum request length exceeded"
HttpException when a user tries to send a file that is greater than 2MB so
that I may tell the user, gracefully, that their file is too big.
Now, my question is where in the world do I add a Handler for
HttpException, apparrently I''m not smart enough to know where this goes or
to find any kind of useful article on the subject (all the ones I have
found, don''t address what I am trying to do, and worse yet don''t give any
real clear examples just vague descriptions).
Thanks,
Chris
这篇关于捕获“超出最大请求长度”的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!