Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the name of the controller and action method in the view in ASP.Net MVC

Tags:

asp.net-mvc

Is there a way in a view in ASP.Net MVC to get the names of the controller and actien method that are using the view?

like image 555
pupeno Avatar asked Jul 05 '09 09:07

pupeno


People also ask

What is action name and controller name in MVC?

Actions are public methods in an MVC controller, that respond to a URL request. Action Selectors are attributes that can be applied to action methods and are used to influence or control which action method gets invoked in response to a request.


1 Answers

Try this:

<%= ViewContext.RouteData.Values["Controller"] %> <%= ViewContext.RouteData.Values["Action"] %> 
like image 183
eu-ge-ne Avatar answered Sep 28 '22 17:09

eu-ge-ne