I have a problem with TempData in MVC5. I know that I can use TempData in the request sequence. However, after I do RedirectToAction, my TempData as well as Session is empty. I am using owin identity configuration. I think that there is something wrong with my Session configuration. But I don't know where to look for that configuration.
I'll share some code examples. Maybe I am doing something wrong and you can help me with that.
So, I have a ParliamentController.cs. Inside that controller I have methods:
[HttpGet]
public ActionResult Politicians()
{
var publishInfo = TempData["Info"];
var sessionInfo = Session["Info"];
return View(new Config());
}
[HttpPost]
public ActionResult PublishConfig()
{
TempData["Info"] = "publish error";
Session["Info"] = "session info";
return RedirectToAction("Politicians", "Parliament", new { area = "Admin" });
}
Also, I have a Politicians.cshtml
Which has this markup:
@using (Html.BeginForm("PublishConfig", "Parliament", FormMethod.Post, new { area = "Admin" }))
{
<input type="submit" value="Publish config"/>
}
And here are some pictures of debugging:
Any help would be appreciated. If you need more details just let me know.
Update: Seems like the issue is only reproducible for Google Chrome browser. Although, an incognito mode in google chrome works well.
I think I've found a solution. The problem was in http protocol. I've tried under the https and everything works as expected. This article helped me to find a solution https://www.petefreitag.com/item/857.cfm