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:
Now all requests to
foo/someactionwill be routed to the corresponding action of theAccountcontroller.