开发者

Facebook SDK MVC CanvasRedirectToAction

I'm trying to pass some value using TempData["SomeValue"] to another action using this.RedirectToAction("Action");

    public ActionResult TestTempData()
    {
        TempData["T开发者_JS百科eamId"] = 1;
        return Facebook.Web.Mvc.CanvasControllerExtensions.CanvasRedirectToAction(this,"TestTempData2");
    }

    public ActionResult TestTempData2()
    {
        if (TempData["TeamId"] == null)
            ViewBag.Title = "NOT FOUND";
        ViewBag.Title = "FOUND";

        return View("Index");
    }

But on the "Action" TempData is always empty can someone help me with this ?


This is because the CanvasRedirectToAction method redirects by writing out a javascript function that then executes when the TestTempData action is loaded.

TempData is only preserved for server-side redirects. If you use RedirectToAction you will have your TempData but the url bar will not change to reflect the current page.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜