Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

TempData fails silently without sessions middleware #3068

Closed
alex-novikov-1990 opened this issue Aug 31, 2015 · 3 comments
Closed

TempData fails silently without sessions middleware #3068

alex-novikov-1990 opened this issue Aug 31, 2015 · 3 comments
Assignees
Milestone

Comments

@alex-novikov-1990
Copy link

Following action results in empty response:

[HttpGet]
public async Task<IActionResult> Index()
{
    TempData["test"] = "test";

    return View(await messageBus.Query(new FindUsers()));
}
@kichalla
Copy link
Member

What version of MVC package are you using? I am able to repro what you are seeing...if you had enabled logging(ex: console, debug or eventlog) you should be seeing a detail like below

System.InvalidOperationException: Session has not been configured for this application or request.
   at Microsoft.AspNet.Http.Internal.DefaultHttpContext.get_Session()
   at Microsoft.AspNet.Mvc.SessionStateTempDataProvider.SaveTempData(HttpContext context, IDictionary`2 values)
   at Microsoft.AspNet.Mvc.TempDataDictionary.Save()
   at Microsoft.AspNet.Mvc.SaveTempDataFilter.OnResourceExecuted(ResourceExecutedContext context)
   at Microsoft.AspNet.Mvc.Core.FilterActionInvoker.<InvokeResourceFilterAsync>d__46.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.AspNet.Mvc.Core.FilterActionInvoker.<InvokeAsync>d__41.MoveNext()

@alex-novikov-1990
Copy link
Author

I'm using beta6 and I didn't see this detail. Problem can be easily reproduced in VS2015 ASP.NET Web Application template by adding TempData to Index action of HomeController.

@danroth27
Copy link
Member

This should probably result in a 500. Today you get a 200.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants