- PageModelExtensions
Class
- RedirectToPageJson<TPageModel>(this TPageModel, string, string, object)
Method
Send 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
Class
Trap 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)
Method
Write an informative, descriptive error message to the configured logger.
- UnhandledExceptionFilter(ILogger<UnhandledExceptionFilter>)
-
UnhandledExceptionFilterLogger
Class
High-performance logging for ASP.NET Core. See: https://learn.microsoft.com/en-us/dotnet/core/extensions/logger-message-generator -
ValidatorActionFilter
Class
Validate non-GET requests from web pages. This is what enables the AJAX-y form submit behavior.
- OnActionExecuted(ActionExecutedContext)
Method
Intentionally blank. - OnActionExecuting(ActionExecutingContext)
Method
Try to validate the request.
- OnActionExecuted(ActionExecutedContext)
-
ValidatorPageFilter
Class
Check 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)
Method
Intentionally blank. - OnPageHandlerExecuting(PageHandlerExecutingContext)
Method
If 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)
Method
Intentionally blank.
- OnPageHandlerExecuted(PageHandlerExecutedContext)
- ModelStateDictionaryExtensions
Class
Extensions to convert ModelStateDictionary errors into JSON responses.- AddModelErrors(this ModelStateDictionary, IReadOnlyCollection<string>)
Method
Add a collection of error messages to ModelState, each with a blank key. - ToJsonErrorResult(this ModelStateDictionary, IReadOnlyCollection<RequestError>)
Method
Creates a 400 Bad Request ContentResult whose body is the JSON-serialized ModelStateDictionary. - ToJsonErrorResult(this ModelStateDictionary)
Method
Creates a 400 Bad Request ContentResult whose body is the JSON-serialized ModelStateDictionary. - ToSlimModelStateDictionary(this ModelStateDictionary)
Method
Only keep the Errors property, and of the errors, only keep the ErrorMessage.
- AddModelErrors(this ModelStateDictionary, IReadOnlyCollection<string>)
- SlimModelStateEntry
Class
For sending model state errors back to the browser without all the extra, unnecessary fluff.- SlimModelStateEntry(IReadOnlyCollection<SlimError>)
Constructor
.ctor - Errors
Property
The collection of model state errors for the request.
- SlimModelStateEntry(IReadOnlyCollection<SlimError>)
- SlimError
Struct
Used to reduce the content of a model state dictionary that's sent back to the browser.- SlimError(string)
Constructor
Used to reduce the content of a model state dictionary that's sent back to the browser. - ErrorMessage
Property
The error message for the request.
- SlimError(string)