带参跳转其他controller

public class GoToOtherController : Controller
{
    public ActionResult Index()
    {
        var vm = new GetValueFromOtherViewModel
        {
            Value="123"
        };
        TempData["GetValueFromOther"] = vm;
        return RedirectToAction("Index", "GetValueFromOther");
    }
}
public class GetValueFromOtherController : Controller
{
    public ActionResult Index()
    {
        var v = TempData["GetValueFromOther"] as GetValueFromOtherViewModel;
        return Json(v.Value,JsonRequestBehavior.AllowGet);
    }
}
public class GetValueFromOtherViewModel
{
    public string Value { get; set; }
}

参考资料

Redirect in a .NET API action filter

posted @ 2018-11-29 20:00  Lulus  阅读(1138)  评论(0编辑  收藏  举报