diff --git a/test/Microsoft.AspNetCore.Mvc.FunctionalTests/RazorPagesTest.cs b/test/Microsoft.AspNetCore.Mvc.FunctionalTests/RazorPagesTest.cs index 8a6610eb7a..ac3bdc29b1 100644 --- a/test/Microsoft.AspNetCore.Mvc.FunctionalTests/RazorPagesTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.FunctionalTests/RazorPagesTest.cs @@ -1011,6 +1011,19 @@ Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary`1[AspNetCore._InjectedP Assert.StartsWith(expected, response.Trim()); } + [Fact] + public async Task Page_WithSection_CanAccessModel() + { + // Arrange + var expected = "Value is 17"; + + // Act + var response = await Client.GetStringAsync("/Pages/Section"); + + // Assert + Assert.StartsWith(expected, response.Trim()); + } + private async Task AddAntiforgeryHeaders(HttpRequestMessage request) { var getResponse = await Client.GetAsync(request.RequestUri); diff --git a/test/WebSites/RazorPagesWebSite/Pages/Section/Index.cshtml b/test/WebSites/RazorPagesWebSite/Pages/Section/Index.cshtml new file mode 100644 index 0000000000..510e36fc40 --- /dev/null +++ b/test/WebSites/RazorPagesWebSite/Pages/Section/Index.cshtml @@ -0,0 +1,10 @@ +@page +@{ + Layout = "_Layout"; +} +@functions { + public int MyValue { get; set; } = 17; +} +@section mysection { + Value is @Model.MyValue +} \ No newline at end of file diff --git a/test/WebSites/RazorPagesWebSite/Pages/Section/_Layout.cshtml b/test/WebSites/RazorPagesWebSite/Pages/Section/_Layout.cshtml new file mode 100644 index 0000000000..bfdb853014 --- /dev/null +++ b/test/WebSites/RazorPagesWebSite/Pages/Section/_Layout.cshtml @@ -0,0 +1 @@ +@RenderSection("mysection") \ No newline at end of file