I have spend lot of time but I am stuck in this error. When I am adding Exception Filter in MVC5 Web Application.
My code is shown as following.
HomeController.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace AutomatedTellerMachine.Controllers
{
public class HomeController : Controller
{
[MyLoggingFilter]
public ActionResult Index()
{
throw new StackOverflowException();
return View();
}
[ActionName("about-this-atm")]
public ActionResult About()
{
ViewBag.Message = "Your application description page.";
return View("About");
}
public ActionResult Contact()
{
ViewBag.TheMessage = "Having trouble? Send us a message.";
return View();
}
[HttpPost]
public ActionResult Contact(string message)
{
ViewBag.TheMessage = "Thanks, we get your meaasge.";
return View();
}
public ActionResult Foo()
{
return View("About");
}
public ActionResult Serial(string letterCase)
{
var serial = "ASPNETMVC5ATM1";
if (letterCase == "lower")
{
return Content(serial.ToLower());
}
return Content(serial);
}
}
}
FilterConfig.cs
using System.Web;
using System.Web.Mvc;
namespace AutomatedTellerMachine
{
public class FilterConfig
{
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute());
filters.Add(new MyLoggingFilterAttribute());
}
}
}
Relevant configuration:
<system.web>
<authentication mode="None"/>
<compilation debug="true" targetFramework="4.5"/>
<httpRuntime targetFramework="4.5"/>
<customErrors mode="On"/>
</system.web>
But nothing is redirecting, something is gone wrong.