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.
精彩评论