ASP.NET MVC故意Ajax失敗

[英]ASP.NET MVC Intentional Ajax Failure


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?

我正在對我的控制器進行ajax調用,這將執行一個長時間的操作。操作可能由於多種原因而失敗或成功。如果我想強制執行我的ajax調用的失敗代碼(“錯誤”),在返回之前我需要在控制器中做什么?只是拋出異常?

1 个解决方案

#1


0  

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

拋出異常將導致狀態代碼= 500,它將調用錯誤處理程序,因此它應該足夠了。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2010/10/23/7258a95028d56c5f4ba4c6513e4b516b.html



 
粤ICP备14056181号  © 2014-2021 ITdaan.com