tags:

views:

113

answers:

1

Hello,

I have Ajax.BeginForm with OnSuccess & OnFailure javascript handlers.

How do fail from my controller so that OnFailure is called?

Yes, I used to call throw new HttpException(404) and it used to work.

But now, I have set a custom error handler that calls Server.ClearError(). Due to this Ajax.BeginForm thinks that no error has occurred.

I am using the error handler given here: http://stackoverflow.com/questions/1171035/asp-net-mvc-custom-error-handling-application-error-global-asax

A: 

You should just be able to throw an Exception. HttpException(404) is Not Found, which I don't think counts as an exception for OnFaiulre. Anything that results in a HTTP 500 should be interpreted as an error by the script.

Dave Swersky