2

If I have an ASP.NET MVC controller action that is called from a jQuery .ajax call that needs to throw an error, how do I do so? I know I can create a JSON object and pass it an "error" property, but what if the response from the .ajax call isn't expected to be JSON but HTML instead?

1
  • so did this turn out to be solved? Commented Feb 2, 2009 at 2:20

1 Answer 1

4

Use the HandleError attribute, and set View to a view which returns the appropriate HTML fragment.

[HandleError(View="AjaxErrorFragment")]
public ActionResult ICallThisWithjQuery() {
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.