- PageModelExtensions
Class- RedirectToPageJson<TPageModel>(this TPageModel, string, string, object)
MethodSend a JsonResult whose object has a redirect property containing the URL that the client JavaScript should
redirect the browser to.
- RedirectToPageJson<TPageModel>(this TPageModel, string, string, object)
-
UnhandledExceptionFilter
ClassTrap and log exceptions that occur in the MVC pipeline so that we can add more context, e.g., controller,
action, and raw URL.The docs say, "Exception filters handle unhandled exceptions, including those that occur during
controller creation and model binding. They are only called when an exception occurs in the pipeline. [...]
Exception filters are good for trapping exceptions that occur within MVC actions."See: https://docs.microsoft.com/en-us/aspnet/core/mvc/controllers/filters#exception-filters
- UnhandledExceptionFilter(ILogger<UnhandledExceptionFilter>)
Constructor.ctor - OnException(ExceptionContext)
MethodWrite an informative, descriptive error message to the configured logger.
- UnhandledExceptionFilter(ILogger<UnhandledExceptionFilter>)
-
UnhandledExceptionFilterLogger
ClassHigh-performance logging for ASP.NET Core. See: https://learn.microsoft.com/en-us/dotnet/core/extensions/logger-message-generator -
ValidatorActionFilter
ClassValidate non-GET requests from web pages. This is what enables the AJAX-y form submit behavior.
- OnActionExecuted(ActionExecutedContext)
MethodIntentionally blank. - OnActionExecuting(ActionExecutingContext)
MethodTry to validate the request.
- OnActionExecuted(ActionExecutedContext)
-
ValidatorPageFilter
ClassCheck the request's ModelState before the Page gets it. If invalid, return a 400 Bad Request. If
it's not a GET, serialize ModelState as JSON and return it in the response body.- OnPageHandlerExecuted(PageHandlerExecutedContext)
MethodIntentionally blank. - OnPageHandlerExecuting(PageHandlerExecutingContext)
MethodIf model state is valid, do nothing. Otherwise, if this is a GET request, return an empty 400 Bad Request.
If this is not a GET request, serialize the ModeState as JSON and return it in the response as a 400 Bad Request. - OnPageHandlerSelected(PageHandlerSelectedContext)
MethodIntentionally blank.
- OnPageHandlerExecuted(PageHandlerExecutedContext)
- ModelStateDictionaryExtensions
ClassExtensions to convert ModelStateDictionary errors into JSON responses.- AddModelErrors(this ModelStateDictionary, IReadOnlyCollection<string>)
MethodAdd a collection of error messages to ModelState, each with a blank key. - ToJsonErrorResult(this ModelStateDictionary, IReadOnlyCollection<RequestError>)
MethodCreates a 400 Bad Request ContentResult whose body is the JSON-serialized ModelStateDictionary. - ToJsonErrorResult(this ModelStateDictionary)
MethodCreates a 400 Bad Request ContentResult whose body is the JSON-serialized ModelStateDictionary. - ToSlimModelStateDictionary(this ModelStateDictionary)
MethodOnly keep the Errors property, and of the errors, only keep the ErrorMessage.
- AddModelErrors(this ModelStateDictionary, IReadOnlyCollection<string>)
- SlimModelStateEntry
ClassFor sending model state errors back to the browser without all the extra, unnecessary fluff.- SlimModelStateEntry(IReadOnlyCollection<SlimError>)
Constructor.ctor - Errors
PropertyThe collection of model state errors for the request.
- SlimModelStateEntry(IReadOnlyCollection<SlimError>)
- SlimError
StructUsed to reduce the content of a model state dictionary that's sent back to the browser.- SlimError(string)
ConstructorUsed to reduce the content of a model state dictionary that's sent back to the browser. - ErrorMessage
PropertyThe error message for the request.
- SlimError(string)