Hi, I had the same problem too, and it was a problem with the implementation of CookieTempDataProvider.
So, I changed the code a bit and now it works fine.
When it reads the data from the cookie, it removes it from the request and response. But add another cookie with an empty value to the SaveData function, which is called when request processing is complete.
Note. If you want to delete the cookie, you must set the timeout value and send it to the client, and then the browser will delete it. We cannot do this otherwise than code whose handler is processed by the browser
And I found out that setting the expiration of DateTime.MinValue does not expire from the cookie in chrome (I don't know about other browsers), so I installed it in 2001-01-01 :)
Here is the working code
public class CookieTempDataProvider : ITempDataProvider { internal const string TempDataCookieKey = "__ControllerTempData"; HttpContextBase _httpContext; public CookieTempDataProvider(HttpContextBase httpContext) { if (httpContext == null) { throw new ArgumentNullException("httpContext"); } _httpContext = httpContext; } public HttpContextBase HttpContext { get { return _httpContext; } } protected virtual IDictionary<string, object> LoadTempData(ControllerContext controllerContext) { if (_httpContext.Request.Cookies.AllKeys.Contains(TempDataCookieKey))
Amila
source share