Can't imagine this question hasn't been asked yet... although, I can't find it.
So here it goes: I've used the ActionNameAttribute a lot on my action methods in ASP.NET MVC 3. Like this:
[ActionName("confirm")]
[HttpGet]
public ActionResult Confirm(string stuffTitle)
{
ActionResult resultView = CreateSomeStuff(stuffTitle);
return resultView;
}
But, how can I accomplish the same for classes? Like this:
[ActionName("personal")]
public class AccountController : Controller
With the ActionNameAttribute it's only possible on method declartions. But I guess it should somehow be possible on class type declarations. Maybe another attribute I haven't heard of yet? Some other workaround?
Anyone an idea? Thanks in advance!!
I really have hard time understanding what are you after. You want to change the name of your controller or something? If so use a route:
routes.MapRoute(
"FooRoute",
"foo/{action}/{action}/{id}",
new { controller = "Account", action = "Index", id = UrlParameter.Optional }
);
Now all requests to foo/someaction
will be routed to the corresponding action of the Account
controller.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With