ASP.NET MVC故意阿贾克斯失败 [英] ASP.NET MVC Intentional Ajax Failure

查看:78
本文介绍了ASP.NET MVC故意阿贾克斯失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想提出一个Ajax调用到我的控制器,将要进行长时间的操作。该操作可能会失败的原因有很多或成功。如果我想迫使我的AJAX调用失败code执行(错误),我需要什么,然后返回在我的控制器呢?只是抛出一个异常?

I am making an ajax call to my controller which is going to perform a long operation. The operation can fail for many reasons or succeed. If I want to force the failure code of my ajax call to execute ("error"), what do I need to do in my controller before returning? Just throw an exception?

推荐答案

抛出异常会导致状态code = 500,将调用错误处理程序,所以它应该是足够了。

Throwing an exception will lead to status code = 500 which will invoke the error handler, so it should be enough.

这篇关于ASP.NET MVC故意阿贾克斯失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆