davidfowl / AspNetCoreDiagnosticScenarios

This repository has examples of broken patterns in ASP.NET Core applications
7.65k stars 736 forks source link

Question about example #118

Open sungam3r opened 6 months ago

sungam3r commented 6 months ago

изображение

As I understand the last line always should fail because of context.Response.WriteAsync("Hello "); nothing to do with next() call here, right?

davidfowl commented 4 months ago

If previously executed middleware is buffering then it won't fail.

sungam3r commented 4 months ago

OK. I understand. My point is about accents in text. Comment says This may fail if next() already wrote to the response focusing reader on next() call but one line above we can see await context.Response.WriteAsync("Hello "); which indeed wrote response regardless any code inside next(). For me line await context.Response.WriteAsync("Hello "); seems confusing and I feel it can be changed to something else (neutral like logging call) or event deleted.