How to prevent interceptor call after action if any exception occure during respective action execution - struts2

I want to prevent interceptor call after action if any exception occurs during action execution in struts2?

Related

Prevent action from execution

How to prevent an action from execution if user types same action and controller in url in mvc4.Suppose I am having Action name as "Prevent" in controller name as "MyDept".Now I want to prevent this action from execution like if user types www.mysite.com/MyDept/Prevent then 404 error or page not found error should be diplayed.
if you have a method in your controller that you don't want it to be accessed decorate it with [NonAction] attribute.

Using ErrorController without raising exceptions

I see the Grails pattern, where you can configure your UrlMappings so that certain types of exceptions are handling in a specific Controller which returns specific responses to your client.
Very good.
However, is there anyway to invoke the functionality of your ErrorController without raising an exception?
For example, a user enters the wrong password - you don't want to throw an exception because it is not really an exception. Instead, you want a service to return an InvalidResponse to a Controller and you would love then for the Controller to delegate out to your ErrorController where you have your generic, error handling.
Can this be done?
Thanks
You can use one of redirect, forward or chain to determine what to do in every case you have

MVC HandleError filter didn't catch an exception

I've an MVC 3 web app in which I'm using "HandleError" Action Filter for exception handling. I've this action filter implemented as follows:
[HandleError]
public class BaseController : Controller {...}
This is the base class from which all of my controllers are derived. In my web.config I've and there's an Error.cshtml in my Shared folder (.cshtml because I use Razor). Everything has been working fine and I get a fine exception handling (formatted by my function)
Recently, somehow I got and "unhandled exception (YSOD)" and because of "customErrors" I got the default ASP.Net error message which didn't have any info about the actual exception. This happened in an AJAX post back. However, I'm unable to reproduce it.
Is it possible for any sort of errors to escape this action filter?
Is it possible for any sort of errors to escape this action filter?
HandleError filter doesn't catch all the exceptions fired in an application. It can capture exceptions that are fired inside actions, action filters.. simply inside the MVC context. Also it doesn't capture HTTP exceptions having status code other than 500. Relying only on HandleError filter in an MVC application is a bad idea.
You should still rely on the Application_Error event to do some logging and customErrors section to display a custom error page for the exceptions that are not captured by HandleError.
I've written a blog post on this subject that may help you.

Custom error view MVC with constructor exception

I'm using the standard set-up with an Error view and HandleErrorAttribute registered in global.asax.
This works fine when an exception is raised from Action, but I don't get a redirect to the error page if an exception is raised in the controller constructor. I don't know why. Is there a separate pattern for handling constructor errors?

ASP.NET MVC OnException and Ajax Form onFailure

The situation I have is I am handling OnException in my controller. Depending on the type of exception I would like to return a javascript result. The action method that threw the exception was called by submitting an ajax form. The ajax form handles the success event. In my OnException method I am setting ExceptionHandled = true per all the examples I've seen. The problem is even though an exception was thrown and I returned a JavascriptResult the success method is called and the javascript I returned isn't executed. Any suggestions as to why this is happening and how I can get the JavascriptResult to execute.
Here's the sequence of events:
the browser sent an ajax request
the action method on the server started executing, and threw an exception.
your OnException method got a chance to look at the exception, and decided to set ExceptionHandled=true.
further, your OnException method returned a JavascriptResult
as ExceptionHandled was set to true, MVC stops the exception processing chain at that point, and returns the JavascriptResult to the browser, with an HTTP result code of 200 OK
The ajax code on the browser receives the result, and interprets it as indicating all is well; it then calls OnComplete, followed by OnSuccess.
Your options are:
Set a status code of 500 on the response before returning from OnException. The browser will call OnComplete, then OnFailure.
Deal with the returned value in OnComplete, instead of in OnSuccess, and then return false to indicate OnSuccess should not be called.

Resources