ASP.NET MVC 4 Override Controller Name

2019-07-23 20:12发布

问题:

Is it possible to override the controller name in ASP.NET MVC 4? It's needed for routing.

There is [ActionName("some-action-name")] attribute to override the action name.

Is it possible to do the same for a controller class name?

It's needed to make a controller name in the routing to have dashes, like "some-controller-name" instead of "SomeControllerName"

回答1:

Solved with routes. It's the only way to do it.

Thanks for comments.