Validating asp net
Jump to Instructions It doesn't matter if your API is nothing more than a facade for simple CRUD operations built on-top of an Active Record implementation or if your API is merely the gateway into your complex Domain Driven Design that leverages the latest and greatest CQSR/ES patterns to scale on demand: you need to validate your input.
Writing code to validate input is quite possibly one of the most tedious task ever created (right next to doing any sort of processing that involves any file format from the medical world).
Aspect Oriented Programming is a way to handle cross-cutting concerns... Filters allow you to execute code in the MVC Action Pipeline prior to the action being executed but after the model had been bound via Action Filters.
While it might sound weird to validate a hidden field, something a user will never directly interact with, in this age of complex interfaces built in Java Script it’s easy to imagine a scenario where a series of interactions leads to storing some kind of value in a hidden field.
If that end value is something that is required, it’s only natural that that should be enforced by the model.
The method attempts to parse the route value to an integer, and if it fails it will set the route value to the default value and restart processing of the route.
Redirect To Route Result restarts the route processing over again, since to get to this point, the method must have changed a route value, and without the redirect, the action would continue on with the original value.