Validating and passing controller-level parameters with ASP.NET MVC attribute routing
问题 I have an ASP.NET controller where every single method will have a shared parameter. With attribute routing, I can add this parameter in the controller's route. However, I still need to add that parameter along with a validation attribute in every single method. Is there a way for me to do the validation in one place or avoid having to pass it in to every single method? This is the current working code: [ApiController] [Route("[controller]/{name}")] public class ExampleController :