C
C#2y ago
devhl

❔ HttpResponse CacheHeaders

I have two questions. Why is this list only returning one item? Also, the server gives me public max-age and sometimes it is max-age. Will Headers.CacheControl.MaxAge work with both?
15 Replies
canton7
canton72y ago
Why is this list only returning one item?
Which list, exactly?
devhl
devhl2y ago
var a only has one item in it.
mtreit
mtreit2y ago
FirstOrDefault Do you know what that does?
devhl
devhl2y ago
ooff okay, lool forest through the trees...
Angius
Angius2y ago
Also, if it returns null, that .Value will throw an exception
devhl
devhl2y ago
yeah I was thinking that too.
mtreit
mtreit2y ago
Actually what is the reason to call ToList in this code?
devhl
devhl2y ago
Only question left is the public max-age and max-age. Do they both show up under Headers.CacheControl.MaxAge var a is just a test
mtreit
mtreit2y ago
I'm not sure where you are seeing public max-age
devhl
devhl2y ago
Sometimes the server gives me one or the other. I don't know the difference.
canton7
canton72y ago
https://learn.microsoft.com/en-us/dotnet/api/system.net.http.headers.cachecontrolheadervalue.public?view=net-7.0
This property represents the "public" directive in a cache-control header field on an HTTP response.
So the public shows up as Headers.CachControl.Public being true/false
devhl
devhl2y ago
Oooohhhh so the cache control header is one string, and the sub headers are just parsed out of it. got it
canton7
canton72y ago
The public and max-age are called directives: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#cache_directives And yeah, they're parsed out separately
devhl
devhl2y ago
Cool thanks. I was doing this wrong. Glad to know.
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts
❔ Need helpHello, Is there any suggestion for a beginner's guide pdf or channel or something to learn I am a ❔ Modern web api frameworks in dotnetIs aspnet the only option for building web apis in modern dotnet? I've tried doing a bunch of search❔ publish blazor wasm app as docker image with nginx baseI create a dockerfile, and create a docker publish configuration, but it tells me that I need to ena❔ ✅ ✅ Why does $singlefile make the .exe file so largeHey I didnt want loads of files so I used $singlefile method and now the exe is 64 megabytes for jus❔ System.IndexOutOfRangeException has been thrown"Index was outside the bounds of the array."Hi I get this message at the line " Tile temp = Tiles[x, y]; " in my SwapTiles method when im trying❔ c# basicsCan anyone help for the test. it falls on Feb 18 and 19. theory and practice is the test, 6-7 tasks ❔ In blazor server,in which Method should you usually implement JWT assignationI have been wondering since I have used scaffolding por identity to receive the JWT token in J's but❔ How does the execution pipeline works with interfaces that implement methods?Lets say we have the icommand interfact, it has to methods : canExcute and Excute, When i bind said❔ WEBAPI [FromBody] Json with optional elementsI am building a .net Wep API application where I will be receiving requests where all of the data is❔ impressC910 shifting position in output trayHow to print with a jogoffset after each x pages by C# code? (Physically ejecting the paper with a l