简体   繁体   English

如何在JQueryUI对话框中使用MVC HandleError属性?

[英]How do I use MVC HandleError attribute with JQueryUI Dialog?

I have HandleError attribute working normally, however: 我有HandleError属性正常工作,但是:

I have a jqueryui dialog that displays a partial view. 我有一个显示部分视图的jqueryui对话框。 If i generate an error in this action the dialog just remains blank and no redirect to the Error.aspx page. 如果我在此操作中产生错误,则对话框将保持空白,并且不会重定向到Error.aspx页。

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. 如果控制器动作中HandleError异常,则HandleError属性会捕获此异常并呈现“ Error视图。 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. 问题是它将StatusCode设置为500。当jQuery看到此状态代码时,它认为请求失败,甚至不费心显示内容。 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. 解决方法是编写一个自定义错误处理程序属性,该属性派生自标准属性,并通过在呈现“错误”视图时将状态代码设置为200来覆盖OnException方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM