How to report error to $.ajax without throwing exception in MVC controller?

前端 未结 7 570
天涯浪人
天涯浪人 2020-12-14 06:53

I have a controller, and a method as defined...

[HttpPost]
public ActionResult UpdateUser(UserInformation model){

   // Instead of throwing exception
   thr         


        
7条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-14 07:16

    Best way I have found is as follows:

    // Return error status and custom message as 'errorThrown' parameter of ajax request
    return new HttpStatusCodeResult(400, "Ajax error test");
    

提交回复
热议问题