2016-06-14 55 views
1

我感興趣的參考作用後 重定向和我希望它是類似於通用返回常規動作後法MVC中控制器

 ActionResult action = new DashboardController().Index(3); 
     return action; 

我想這樣的代碼

因爲我使用POST 重定向到一個網頁,我不能用這個

return RedirectToAction(actionName, controllerName); 

Example

 public ActionResult generic(string Controller,string Action) 
     { 
      Assembly asm = Assembly.GetAssembly(typeof(MvcApplication)); 

      var controlleractionlist = asm.GetTypes() 
        .Where(type => typeof(Controller).IsAssignableFrom(type)); 

      return typeof(typeof(controlleractionlist).GetProperty(Controller)) 
      .GetProperty(Action); 
      } 

鏈接可以幫助也許答案 Link 1 link 2

我提前爲我的英語

回答

-3

道歉試試這個,如果它工作

ActionResult instance=new ControllerClass()Index(parameters); 
return instance; 
+0

我只是想只是通用的,我可以發送每一個不同的t控制器和不同的行動 –