/// <summary> /// Displays the <c>~/Views/Shared/NotFound.cshtml</c> view when a controller is not found, an action is not found, or the action returns the <see cref="HttpNotFoundResult"/> view result. /// </summary> /// <param name="builder">The application builder.</param> public static void UseNotFoundHandler(this ApplicationBuilder builder) { var currentFactory = ControllerBuilder.Current.GetControllerFactory(); var currentFactoryWrapper = new ControllerFactoryWrapper(currentFactory); ControllerBuilder.Current.SetControllerFactory(currentFactoryWrapper); GlobalFilters.Filters.Add(new HandleNotFoundErrorAttribute()); }