How do you trigger the “error” callback in a jQuery AJAX call using ASP.NET MVC?

后端 未结 6 1500
心在旅途
心在旅途 2020-12-12 21:04

This is related to my question on how to handle errors from jQuery AJAX calls. Several responses suggested that I use the \"error\" callback to display any errors from a jQ

6条回答
  •  生来不讨喜
    2020-12-12 21:46

    If you're using

    [HandleError]
    

    then throwing a HttpException is going to get caught and routed to your custom error page.

    Another option is to use

    Response.StatusCode = 500;
    Response.Write("Error Message");
    Response.End();
    

    There's probably a more convenient way to write this but I haven't stumbled upon it yet.

提交回复
热议问题