Note that there are some explanatory texts on larger screens.

plurals
  1. POApplication Error not fired for 404 page when extra custom segment
    primarykey
    data
    text
    <p>I have a asp.net mvc 3 application with IIS7 and IIS express on local, which is using Application_Error for logging the exceptions and redirecting to a custom error page. My application has different regions, and the application_error is called whenever the controller or the action is not matched, but not for the region.</p> <p>Here is an example of the routes used:</p> <pre><code>routes.MapRoute( "Default", "{region}/{controller}/{action}/{id}", new { region = "uk", controller = "Home", action = "Index", id = UrlParameter.Optional }, // Parameter defaults new { region = new RegionWhitelistConstraint() } // constraint for valid regions ); </code></pre> <p>In this case the Application_Error would be fired for /uk/NotFoundPage but not for /foo/Home</p> <p>Here the constraint for the region:</p> <pre><code>public class RegionWhitelistConstraint : IRouteConstraint { public bool Match(System.Web.HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) { var whiteList = Region.DefaultWhiteList; var currentRegionValue = values[parameterName].ToString(); return whiteList.Contains(currentRegionValue); } } </code></pre> <p>I have seen <a href="https://stackoverflow.com/questions/6990677/application-error-not-fired-for-404-in-mvc-3-when-url-contains-4-or-more-path-se">this</a> question, that propose adding a catch all route, but apart from that I would like to know if there is a way of firing Application_Error as it is done for the controllers or actions.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload