How to check which action method rendered the current view (from within the current view)?
I would like to know how to check which a开发者_开发知识库ction displayed the current View (from the current view).
For instance, to check if controller myController originated the rendering (I guess) I can write:
<% if(ViewContext.Controller is myApplication.Controllers.myController)%>
In fact, I want to use the same View model for 2 actions methods, like this:
<% If( First Action rendered this view){%>
// Display this
<%} else {%>
//Display that
<%}%>
Thanks for helping
You may use ViewData for storing name of Action from which view is being rendered
OR
Use ViewContext.RouteData.Values["action"]
for pulling out the action name out of RouteData
use ViewContext.RouteData.Values["action"]
精彩评论