diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/FlushPointTest.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/FlushPointTest.cs
index efcfcba7de..0adaa3fb08 100644
--- a/test/Microsoft.AspNet.Mvc.FunctionalTests/FlushPointTest.cs
+++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/FlushPointTest.cs
@@ -63,7 +63,18 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
waitService.WaitForServer();
// Assert - 3
- Assert.Equal("Final content", GetTrimmedString(stream));
+ Assert.Equal("Inside partial", GetTrimmedString(stream));
+ waitService.WaitForServer();
+
+ // Assert - 4
+ Assert.Equal(@"After flush inside partial
+
",
+ GetTrimmedString(stream));
}
[Theory]
@@ -105,6 +116,59 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
"More content from layout"), GetTrimmedString(stream));
}
+ [Fact]
+ public async Task FlushPointsNestedLayout()
+ {
+ // Arrange
+ var waitService = new WaitService();
+ var serviceProvider = GetServiceProvider(waitService);
+
+ var server = TestServer.Create(serviceProvider, _app);
+ var client = server.CreateClient();
+
+ // Act
+ var stream = await client.GetStreamAsync("http://localhost/FlushPoint/PageWithNestedLayout");
+
+ // Assert - 1
+ Assert.Equal(@"Inside Nested Layout
+
+Nested Page With Layout",
+ GetTrimmedString(stream));
+ waitService.WaitForServer();
+
+ // Assert - 2
+ Assert.Equal("Nested content that takes time to produce", GetTrimmedString(stream));
+ }
+
+ [Fact]
+ public async Task FlushBeforeCallingLayout()
+ {
+ var waitService = new WaitService();
+ var serviceProvider = GetServiceProvider(waitService);
+
+ var server = TestServer.Create(serviceProvider, _app);
+ var client = server.CreateClient();
+
+ var expectedMessage = "A layout page cannot be rendered after 'FlushAsync' has been invoked.";
+
+ // Act
+ var stream = await client.GetStreamAsync("http://localhost/FlushPoint/PageWithFlushBeforeLayout");
+
+ // Assert - 1
+ Assert.Equal("Initial content", GetTrimmedString(stream));
+ waitService.WaitForServer();
+
+ //Assert - 2
+ try
+ {
+ GetTrimmedString(stream);
+ }
+ catch (Exception ex)
+ {
+ Assert.Equal(expectedMessage, ex.InnerException.Message);
+ }
+ }
+
private IServiceProvider GetServiceProvider(WaitService waitService)
{
var services = new ServiceCollection();
diff --git a/test/WebSites/RazorWebSite/Controllers/FlushPoint.cs b/test/WebSites/RazorWebSite/Controllers/FlushPoint.cs
index f8f47ebb23..d8625a98b1 100644
--- a/test/WebSites/RazorWebSite/Controllers/FlushPoint.cs
+++ b/test/WebSites/RazorWebSite/Controllers/FlushPoint.cs
@@ -28,5 +28,15 @@ namespace RazorWebSite
{
return View("PageWithSectionInvokedViaRenderSectionAsync");
}
+
+ public ViewResult PageWithNestedLayout()
+ {
+ return View();
+ }
+
+ public ViewResult PageWithFlushBeforeLayout()
+ {
+ return View();
+ }
}
}
\ No newline at end of file
diff --git a/test/WebSites/RazorWebSite/Views/FlushPoint/PageWithFlushBeforeLayout.cshtml b/test/WebSites/RazorWebSite/Views/FlushPoint/PageWithFlushBeforeLayout.cshtml
new file mode 100644
index 0000000000..3473b46cdd
--- /dev/null
+++ b/test/WebSites/RazorWebSite/Views/FlushPoint/PageWithFlushBeforeLayout.cshtml
@@ -0,0 +1,10 @@
+@inject WaitService WaitService
+Initial content
+@await FlushAsync()
+@{
+ WaitService.WaitForClient();
+}
+
+@{
+ Layout = "/Views/Shared/_LayoutWithFlush.cshtml";
+}
diff --git a/test/WebSites/RazorWebSite/Views/FlushPoint/PageWithNestedLayout.cshtml b/test/WebSites/RazorWebSite/Views/FlushPoint/PageWithNestedLayout.cshtml
new file mode 100644
index 0000000000..9dd03ccac4
--- /dev/null
+++ b/test/WebSites/RazorWebSite/Views/FlushPoint/PageWithNestedLayout.cshtml
@@ -0,0 +1,6 @@
+@inject WaitService WaitService
+@{
+ Layout = "/Views/Shared/_NestedLayoutWithFlush.cshtml";
+ ViewBag.Title = "Nested Page With Layout";
+}
+@ViewBag.Title
\ No newline at end of file
diff --git a/test/WebSites/RazorWebSite/Views/FlushPoint/PageWithoutLayout.cshtml b/test/WebSites/RazorWebSite/Views/FlushPoint/PageWithoutLayout.cshtml
index b25b173026..217ba18738 100644
--- a/test/WebSites/RazorWebSite/Views/FlushPoint/PageWithoutLayout.cshtml
+++ b/test/WebSites/RazorWebSite/Views/FlushPoint/PageWithoutLayout.cshtml
@@ -9,7 +9,16 @@ Secondary content
@{
WaitService.WaitForClient();
}
-Final content
+@{
+ await Html.RenderPartialAsync("_PartialWithFlush");
+}
+@using (Html.BeginForm())
+{
+ @Html.TextBox("Name1")
+ @await FlushAsync()
+ WaitService.WaitForClient();
+ @Html.TextBox("Name2")
+}
@{
WaitService.NotifyClient();
}
\ No newline at end of file
diff --git a/test/WebSites/RazorWebSite/Views/Shared/_LayoutWithRenderSectionOnly.cshtml b/test/WebSites/RazorWebSite/Views/Shared/_LayoutWithRenderSectionOnly.cshtml
new file mode 100644
index 0000000000..c3caff06ad
--- /dev/null
+++ b/test/WebSites/RazorWebSite/Views/Shared/_LayoutWithRenderSectionOnly.cshtml
@@ -0,0 +1,2 @@
+@RenderBody()
+@await RenderSectionAsync("nestedcontent")
\ No newline at end of file
diff --git a/test/WebSites/RazorWebSite/Views/Shared/_NestedLayoutWithFlush.cshtml b/test/WebSites/RazorWebSite/Views/Shared/_NestedLayoutWithFlush.cshtml
new file mode 100644
index 0000000000..d127d570ac
--- /dev/null
+++ b/test/WebSites/RazorWebSite/Views/Shared/_NestedLayoutWithFlush.cshtml
@@ -0,0 +1,16 @@
+@inject WaitService WaitService
+@{
+ Layout = "/Views/Shared/_LayoutWithRenderSectionOnly.cshtml";
+ ViewBag.Title = "Page With Layout";
+}
+Inside Nested Layout
+@RenderBody()
+@section nestedcontent
+{
+ @{
+ await FlushAsync();
+ WaitService.WaitForClient();
+ }
+ Nested content that takes time to produce
+}
+
diff --git a/test/WebSites/RazorWebSite/Views/Shared/_PartialWithFlush.cshtml b/test/WebSites/RazorWebSite/Views/Shared/_PartialWithFlush.cshtml
new file mode 100644
index 0000000000..de296ced2a
--- /dev/null
+++ b/test/WebSites/RazorWebSite/Views/Shared/_PartialWithFlush.cshtml
@@ -0,0 +1,7 @@
+@inject WaitService WaitService
+Inside partial
+@await FlushAsync()
+@{
+ WaitService.WaitForClient();
+}
+After flush inside partial
\ No newline at end of file