-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Adding support for flush points in Razor pages #1048
Conversation
<strong>Marketing:</strong> <a href="mailto:[email protected]">[email protected]</a> | ||
</address> | ||
|
||
@* Todo replace with await when we have support for async sections *@ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggest placing this at the top of the section to make delay more visible
|
||
// Assert | ||
var body = await result.HttpContext.Response.ReadBodyAsStringAsync(); | ||
Assert.Equal(expected, body.Trim()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about this test demonstrates the flush point is anything but a noop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Part of it was to simply verify if the page executes. I think the right test would be to check if we get the appropriate number of chunks with the contents split for each invocation of Flush. The API that we have on client
isn't extensive enough to allow this. I an speak to @javiercn to figure out if there's some way to get to the raw results
923094c
to
746f219
Compare
b0fb438
to
08eac45
Compare
|
Updated. FYI @yishaigalatzer nested sections don't work (and did not in Mvc 5). Regardless, this approach would allow it but we can't write a functional test for it. |
I'm pretty excited about this PR! To be fair I petitioned for this feature pretty hard... One word of warning, that I found via the library I hacked toget to emulate this (called CourtesyFlush): in MVC 5, Html.AntiForgeryToken() writes to the HTTP headers to set a cookie from the view. This means that AntiForgeryToken, with its current implementation, cannot work after a flush. I had to reimplement AntiForgeryToken for my library to work and provide an option to set the cookie at the flush point. Perhaps you can do something more clever, or at least allow for FlushAsync(includeAntiForgeryToken: true) Let me know if this makes sense or not. |
@nikmd23 that is a great reminder. Opened a followup item #1079 @NTaylorMullen @DamianEdwards this is something we need to account for in the form taghelper as well. |
|
Fixes #1042