Can I use TempData with Response.Redirect?


Can I use TempData with Response.Redirect?



I am working with ASP.net MVC 2 framework, for multiple sites. We have a base site and then sub sites that inherit from a "Core" site that contains 90% of the functionality that the sub sites will use.

In one of the controllers, I am saving some data, adding a UI message to the tempData and then using Response.Redirect.

The redirect works, but the tempdata is empty after the redirect.

I have tried returning "RedirectToAction" and "RedirectToRoute" with the same routing location and while it populates the TempData, the redirect doesn't happen lol..

So I guess in short, is there a way to get tempdata working when using a standard Response.Redirect?

Thanks in advanced!


asp.net mvc model item passed in to dictionary is of type List

1:

Why is my selected value showing up twice in a dropdownlist (asp.net mvc)
TempData is intended for redirects. Interface arguments in ASP.NET MVCBut in MVC 2+, reading TempData causes the token to be deleted. Auto generate grid using mvccontrib by passing datatable in ASP.net MVC 2 applicationSo code like this:. WebMatrix, ASP.NET Razor, IIS Developer Express, SQL Server Compact Edition - What is Microsoft objective behind these new technologies?
if (!string.IsNullOrEmpty(TempData["Foo"].AsString()) { foo =  TempData["Foo"].AsString(); } 
... Mocking and Stubbing Ajax Requestsis now broken. using jquery datatable for server side processing with paging, filtering and searchBut this code:. how do I use mvc data annotations in conjunction with auto generated linqtosql classes
var bar = TempData["Foo"].AsString(); if (!string.IsNullOrEmpty(bar)) { foo = bar; } 
...still works..


55 out of 100 based on 70 user ratings 465 reviews

*