parent
275d03a958
commit
d8455c3e64
|
|
@ -45,8 +45,8 @@
|
|||
<strong>Marketing:</strong> <a href="mailto:Marketing@example.com">Marketing@example.com</a>
|
||||
</address>
|
||||
|
||||
@await FlushAsync()
|
||||
@{
|
||||
await FlushAsync();
|
||||
await Task.Delay(TimeSpan.FromSeconds(1));
|
||||
}
|
||||
<div class="row">
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="container body-content">
|
||||
@{ await FlushAsync(); }
|
||||
@await FlushAsync()
|
||||
@RenderBody()
|
||||
@RenderSection("content")
|
||||
<hr />
|
||||
|
|
|
|||
|
|
@ -544,8 +544,11 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
/// Invokes <see cref="TextWriter.FlushAsync"/> on <see cref="Output"/> writing out any buffered
|
||||
/// content to the <see cref="HttpResponse.Body"/>.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="Task"/> that represents the asynchronous flush operation.</returns>
|
||||
public Task FlushAsync()
|
||||
/// <returns>A<see cref="Task{HtmlString}"/> that represents the asynchronous flush operation and on
|
||||
/// completion returns a <see cref="HtmlString.Empty"/>.</returns>
|
||||
/// <remarks>The value returned is a token value that allows FlushAsync to succeed. However the
|
||||
/// value does not represent the rendered content.</remarks>
|
||||
public async Task<HtmlString> FlushAsync()
|
||||
{
|
||||
// If there are active writing scopes then we should throw. Cannot flush content that has the potential to
|
||||
// change.
|
||||
|
|
@ -562,7 +565,8 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
throw new InvalidOperationException(message);
|
||||
}
|
||||
|
||||
return Output.FlushAsync();
|
||||
await Output.FlushAsync();
|
||||
return HtmlString.Empty;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
|
|
|||
|
|
@ -98,10 +98,10 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
{
|
||||
// Arrange
|
||||
var viewContext = CreateViewContext();
|
||||
var page = CreatePage(v =>
|
||||
var page = CreatePage(async v =>
|
||||
{
|
||||
v.StartWritingScope();
|
||||
v.FlushAsync();
|
||||
await v.FlushAsync();
|
||||
});
|
||||
|
||||
// Act
|
||||
|
|
@ -527,6 +527,25 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
await Assert.DoesNotThrowAsync(() => renderAsyncDelegate(TextWriter.Null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task FlushAsync_ReturnsEmptyHtmlString()
|
||||
{
|
||||
// Arrange
|
||||
HtmlString actual = null;
|
||||
var writer = new Mock<TextWriter>();
|
||||
var context = CreateViewContext(writer.Object);
|
||||
var page = CreatePage(async p =>
|
||||
{
|
||||
actual = await p.FlushAsync();
|
||||
}, context);
|
||||
|
||||
// Act
|
||||
await page.ExecuteAsync();
|
||||
|
||||
// Assert
|
||||
Assert.Same(HtmlString.Empty, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WriteAttribute_CallsBeginAndEndContext_OnPageExecutionListenerContext()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
@inject WaitService WaitService
|
||||
Initial content
|
||||
@await FlushAsync()
|
||||
@{
|
||||
await FlushAsync();
|
||||
WaitService.WaitForClient();
|
||||
}
|
||||
Secondary content
|
||||
@await FlushAsync()
|
||||
@{
|
||||
await FlushAsync();
|
||||
WaitService.WaitForClient();
|
||||
}
|
||||
Final content
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
@inject WaitService WaitService
|
||||
<title>@ViewBag.Title</title>
|
||||
@await FlushAsync()
|
||||
@{
|
||||
await FlushAsync();
|
||||
WaitService.WaitForClient();
|
||||
}
|
||||
@RenderBody()
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
@inject WaitService WaitService
|
||||
<title>@ViewBag.Title</title>
|
||||
@RenderBody()
|
||||
@await FlushAsync()
|
||||
@{
|
||||
await FlushAsync();
|
||||
WaitService.WaitForClient();
|
||||
}
|
||||
@await Html.PartialAsync("_PartialThatSetsTitle")
|
||||
|
|
|
|||
Loading…
Reference in New Issue