I have the following tempdata in my controller:
public ActionResult Index(string query = null)
{
TempData["message"] = string.Format("test message");
return RedirectToAction("Index", "Posts");
}
And in my _layout.cshtml file I have the following:
@if (TempData["message"] != null)
{
<div class="message">@TempData["message"]</div>
}
But nothing get displayed. If do the following i.e. no redirect from my controller method, the message gets displayed.
public ActionResult Index(string query = null)
{
TempData["message"] = string.Format("test message");
return View();
}
So basically it doesnt seem to work on RedirectToAction. Strangely it was working before so not sure what has happend all of a sudden?
Any ideas?