Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

filterContext for ActionResult in OnResultExecuted Method of ASP.NET MVC

I need to filter only methods from all actions which have return type ActionResult from controller actions. I am getting controller name and action name from following..

string originController = filterContext.RouteData.Values["controller"].ToString();
string originAction = filterContext.RouteData.Values["action"].ToString();

but how can i filter only method which have return type ActionResult?

like image 490
Naveen Katakam Avatar asked Jul 25 '13 08:07

Naveen Katakam


1 Answers

Try this kind of code for accessing Controllers, Actions as well as

  string originController = filterContext.RouteData.Values["controller"].ToString();
  string originAction = filterContext.RouteData.Values["action"].ToString();
  string originArea = String.Empty;
   if (filterContext.RouteData.DataTokens.ContainsKey("area"))
       originArea = filterContext.RouteData.DataTokens["area"].ToString();
like image 107
user2964804 Avatar answered Sep 19 '22 06:09

user2964804