如何将dfd,dtd和soprtr变量用于另一个动作?

时间:2014-02-19 06:52:24

标签: asp.net-mvc-3 razorengine

[HttpPost]

     public ActionResult crbtmis(string submitbuttonoperator, DateTime fromdate, DateTime todate, string operatorname)
     {
        DateTime dfd = fromdate;
        DateTime dtd = todate;
        string soprtr = operatorname;
         if (Session["user"] != null && Session["user"].ToString() == "MISADMIN")
         {

             switch (submitbuttonoperator)
             {
                 case "Export":
                     return (ExportOprtrlist( fromdate, todate, operatorname));
                 case "Search":
                     return (SearchByOperator());
                 default:
                     return (View("LogOn"));
             }
         }
         else
         {
             return RedirectToAction("LogOn");
         }
     }

我定义了三个名为dfd,dtd和soprtr的变量,并希望将这些变量用于另一个ActionResult。现在请帮帮我,我该怎么做?

1 个答案:

答案 0 :(得分:1)

在您的操作中,您可以使用包含一些参数的其他操作:

public ActionResult crbtmis(string submitbuttonoperator, DateTime fromdate, DateTime todate, string operatorname)
    {
       //..your code
       return RedirectToAction("OtherAction", new { dfd  = dfd, dtd = dtd, soprtr = soprtr });
    }