I'm trying to understand HandleErrorAttribute in MVC3. (I also followed old article from ScottGu) I added the <customErrors mode="On" />
to the web.config
file. All errors redirect to the \Views\Shared\Error.cshtml
view. If I keep the HandleErrorAttribute
or remove from the controller, there is no difference in the behavior.
Code of the controller
public class HomeController : Controller
{
[HandleError]
public ActionResult Index()
{
ViewBag.Message = "Welcome to ASP.NET MVC!";
throw new Exception();
return View();
}
}
Also, I show in some articles and SO post, that with <error redirect="..."/>
, request can be redirected to the required view.
Qestions
- What is the use of
HandleErrorAttribute
? - What is the advantage of using it over
<customErrors..
? - What can we achieve that is not achievable by
<customErrors..
?