开发者

How do I use MVC HandleError attribute with JQueryUI Dialog?

开发者 https://www.devze.com 2023-01-18 02:55 出处:网络
I have HandleErro开发者_如何学编程r attribute working normally, however: I have a jqueryui dialog that displays a partial view. If i generate an error in this action the dialog just remains blank and

I have HandleErro开发者_如何学编程r attribute working normally, however:

I have a jqueryui dialog that displays a partial view. If i generate an error in this action the dialog just remains blank and no redirect to the Error.aspx page.

What do I need to do to get this to work?


In case an exception inside a controller action the HandleError attribute catches this exception and renders the Error view. Problem is it sets the StatusCode to 500. When jQuery sees this status code it considers the request failed and doesn't even bother to show the contents. On way to workaround this is to write a custom error handler attribute deriving from the standard one and overriding the OnException method by setting the status code to 200 when rendering the Error view.

0

精彩评论

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