-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Action method returns empty response after setting TempData #7003
Comments
Here is the relevant part of the exception
The Is it by design ? Are we only supposed to use simply types mentioned in Here is the simple class i was using
|
@kshyju yes, the |
Thanks ! Any idea why it is not throwing/showing the error message in the browser or firing up the developer exception page ? (I used VS Output->Debug window to get the exception details) |
Serialization of TempData is one of the few things that happens outside of the middleware pipeline (https://github.com/aspnet/Mvc/blob/dev/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Internal/SaveTempDataFilter.cs#L46) which explains why you don't see the error in the diagnostics middleware. @Tratcher could we do something to make the experience for reporting errors thrown as part of Response.OnStarting better? |
OnStarting is called directly by the server, the best it can do is log. In practice we don't use OnStarting in most components because of the ordering and error handling confusion. Do you really need it for temp data? Would you be better off processing temp data as a result filter of some sort? |
The diagnostics middleware could wrap OnStarting callbacks and report any exceptions by decorating IHttpResponseFeature. Not saying it's a good idea, but it's possible. |
Yes, but it would be outside of the request control flow so it couldn't react to the exception. |
The handling of error scenarios is much better since #6598. Tracking further improvement of error reporting via dotnet/aspnetcore#2851 |
When i set an object of my custom class to TempData and try to do a Redirect, I get a 500 error. As per 2.0, CookieTempData provider is default. So i do not have any explicit mapping for
ITempDataProvider
toCookieTempDataProvider
The code i am trying
This never hits About action method. I inspected the network calls and the browser never gets a 302 response when i submit the form to the HttpPost Index action.
Chrome dev tools shows
Status Code:500 Internal Server Error
in General header sectionResponse headers are
I have the exception page enabled in Startup, but still not seeing any errors
This is the error message i get in chrome
This page isn’t working
localhost is currently unable to handle this request.
HTTP ERROR 500
--
Here is a minimal repo where i reproduced the issue
The text was updated successfully, but these errors were encountered: