ASP.NET MVC Intentional Ajax Failure

梦想的初衷 提交于 2019-12-11 15:48:20

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/4002795/asp-net-mvc-intentional-ajax-failure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!