I am using ASP.NET MVC 4.5.1 razor C#
My Web.config is configured with one of the below tags.
<customErrors mode="On" defaultRedirect="Error">
<error statusCode="404" redirect="/Error.htm"/>
</customErrors>
I have a class to catch all exceptions like below.
public class Error : HandleErrorAttribute
{
public override void OnException(ExceptionContext filterContext)
{
base.OnException(filterContext);
}
}
My Base Controller is like below.
[Error]
public class BaseController : AsyncController
{
}
My Controller Action Method is like below
[HttpGet, Route("All-User"), LoginAuthentication, AdminAuthorization]
public async Task<ActionResult> AllUsers()
{
var list = await _user.List();
return View(list);
}
My Url is like below and works perfectly
localhost/All-User
When I execute below url, I get 404 but catch block of Error class is not being executed.
localhost/All-Userabc
Am I missing something ?
I also tried to Install-Package NotFoundMvc
but this is not working and getting an exception "Invalid Operation Exception"