-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Closed
Closed
Copy link
Labels
investigateold-area-web-frameworks-do-not-use*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels
Milestone
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
In ASP.NET Core Web API (MVC),I received An unhandled exception occurred while processing the request.
InvalidOperationException: If the 'NoStore' property is not set to true, 'Duration' property must be specified.
Microsoft.AspNetCore.Mvc.Filters.ResponseCacheFilterExecutor.Execute(FilterContext context)
I set the cacheProfile.Location
ResponseCacheLocation.None
, the Cache-Control
response header should have been set to no-cache
, but it threw an exception. If I set Duration = 0
, the value of the response header will become no-cache,max-age=0
, which doesn't seem reasonable.
Expected Behavior
When I set Location
to None
, it should not throw an exception, and set the value of the response header to no-cache
without max-age
.
Steps To Reproduce
- Clone https://github.com/lc6464/api.lcwebsite.cn.git
- Remove
Duration = 0,
inProgram.cs:39
- Changed
Private1m
toNoCache
inControllers\GetIPController.cs:18
. - Build
- Visit
http://localhost:5000/GetIP
Exceptions (if any)
An unhandled exception occurred while processing the request.
InvalidOperationException: If the 'NoStore' property is not set to true, 'Duration' property must be specified.
Microsoft.AspNetCore.Mvc.Filters.ResponseCacheFilterExecutor.Execute(FilterContext context)
.NET Version
6.0.302
Anything else?
ASP.NET Core 6.0
Visual Studio 2022 17.2.6
dotnet --info
:
.NET SDK (反映任何 global.json):
Version: 6.0.302
Commit: c857713418
运行时环境:
OS Name: Windows
OS Version: 10.0.22621
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\6.0.302\
global.json file:
Not found
Host:
Version: 6.0.7
Architecture: x64
Commit: 0ec02c8c96
Metadata
Metadata
Assignees
Labels
investigateold-area-web-frameworks-do-not-use*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels