How to check which action method rendered the current view (from within the current view) ?
Posted
by Richard77
on Stack Overflow
See other posts from Stack Overflow
or by Richard77
Published on 2010-03-24T08:24:11Z
Indexed on
2010/03/24
8:53 UTC
Read the original article
Hit count: 249
asp.net-mvc
Hello,
I would like to know how to check which action 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
© Stack Overflow or respective owner