-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
If-None-Match and If-Modified-Since headers not being process by .NET 6 on VS 2022 #36291
Comments
having the same issue myself, and i could be wrong, but for my case it seems to be |
@mrtluke this is very interesting, the browser link is also disabled on my VS2022. However, disabling the "Hot Reload CSS Changes" fixed the issue with etag. |
I can reproduce the issue with Setting the option Simpler code to repro: var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.MapGet("/", async context =>
{
await context.Response.WriteAsync(context.Request.Headers
.Aggregate(string.Empty, (result, header) => result += $"{header.Key}: {header.Value}\r\n"));
});
app.Run(); Repro on VS 17.0.0 Preview 4.1 and .NET 6.0 RC1 |
@jodavis Could you help with this issue? |
@vgmello @mrtluke The "Hot Reload CSS changes" setting is removing those headers. It needs to inject a script to make the feature work. Assuming the browser's cached copy won't contain the script (or won't contain the right URL, since the port can change) it clears those headers to break the cache. It's smarter with ETags. It modifies the ETag in a way that includes the URL, so the browser's cached content can be used as long as the URL doesn't change. |
@jodavis thanks for the reply.
in my case, this is affecting a custom json/object controller that is trying to handle these headers (and produces the etag itself, for its own requests). the hot reloading in general is a great thing to have for the UI, so it completely makes sense for that scenario, but not really for a custom controller thats trying to handle the client/requests. maybe im not on the same page or im forgetting other scenarios, so just my two cents from my view. |
@mrtluke Good point, we have a filter further in the codepath that decides whether or not to inject the script, and it wouldn't inject in the case of non-HTML responses. We should avoid affecting these headers in that case. I'll file an issue to fix this in Visual Studio. |
@jodavis sounds great, thank you. |
Hmm. Seems I was looking into wrong repo. Created a duplicate in: #39516. |
You know what would be even smarter? Writing a hot reloader which gets sent hot patches via a different URL altogether which contains a cache busting token so you never have to mess with headers that result in dumb situations such as poorly written code stripping out perfectly valid cache headers on resources that have zero to do with CSS under the purview of hot reloading. Microsoft should have a little look at prior art which gets this right, like Webpack. And then spend some time ripping out their botched job and redoing it properly. Arrived here from #39516 and I'm sorry to say: at the moment it doesn't surprise me in the slightest anymore that, once again, this turns out to be a problem with the atrocious implementation of hot reloading for ASP.NET that is injected when using VS 2022. Just like the asinine problem where it can completely corrupt any content sent with GZip or Brotli compression because the middleware that injects the hot reloading scripts is dumb as bricks and will gleefully attempt injection directly into a compressed stream of content, wherever it finds what it (very, very falsely) believes to be the marker for the insertion point. |
Can I close this issue since there is no action to do in aspnet? |
Describe the bug
I'm not sure if this issue should be reported here or as a VS 2022 bug, however, for some reason whenever an aspnet app is started within VS 2022 even without the debugger attached, the app can not read the
If-None-Match
andIf-Modified-Since
request headers, there are never included in header collection. I'm experiencing this behavior in both Kestrel and IIS Express, and with minimal APIs and normal controllers. Everything works fine if I target docker as launch profile.To Reproduce
Dummy code
Exceptions (if any)
No exceptions were thrown
Further technical details
Framework: Tests on .NET 5 and .NET 6
Environment
IDE:
The text was updated successfully, but these errors were encountered: