Specifying order is very important if you use HandleError Filter Attribute.
If you want your Specific Exception Eg. Divide By Zero Error, to be viewed in MathError.aspx page and all other exception in default "Error.aspx" page.
Do the Order as follows.
[HandleError(Order =1, ExceptionType = typeof(DivideByZeroException), View = "MathError")]
[HandleError(Order=2)]
Also if you want to override the HandleError behaviour of class in the Action method you can do that by specifying the attribute in the method.
Sample
[HandleError(ExceptionType = typeof(DivideByZeroException), View = "ActionError")]
public ActionResult MaskEdit()
{
return View();
}
The reason behind specifying the Order is because Controller runtime is free to reorder attribute declarations in any manner it chooses, which is why the Order property is there in the first place,
If no Order is specified, we'll just execute the filters in the order given to us by the runtime.
No comments:
Post a Comment