From ccab23fe532333ea419ac6de87360de01d14b379 Mon Sep 17 00:00:00 2001 From: Scott Addie Date: Wed, 17 Oct 2018 17:14:06 -0500 Subject: [PATCH 1/4] Add detail about serving partial views named with underscores --- aspnetcore/mvc/views/partial.md | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/aspnetcore/mvc/views/partial.md b/aspnetcore/mvc/views/partial.md index 81c2a45d76..65bb60bace 100644 --- a/aspnetcore/mvc/views/partial.md +++ b/aspnetcore/mvc/views/partial.md @@ -38,7 +38,7 @@ Don't use a partial view where complex rendering logic or code execution is requ ## Declare partial views -::: moniker range=">= aspnetcore-2.1" +::: moniker range=">= aspnetcore-2.0" A partial view is a *.cshtml* markup file maintained within the *Views* folder (MVC) or *Pages* folder (Razor Pages). @@ -46,11 +46,23 @@ In ASP.NET Core MVC, a controller's i Unlike MVC view or page rendering, a partial view doesn't run *_ViewStart.cshtml*. For more information on *_ViewStart.cshtml*, see . -Partial view file names often begin with an underscore (`_`). This naming convention isn't required, but it helps to visually differentiate partial views from views and pages. When the file name starts with an underscore, Razor Pages doesn't process the markup file as a Razor Pages page, even when the file's markup includes the `@page` directive. +Partial view file names often begin with an underscore (`_`). This naming convention isn't required, but it helps to visually differentiate partial views from views and pages. ::: moniker-end -::: moniker range="< aspnetcore-2.1" +::: moniker range="= aspnetcore-2.1" + +In ASP.NET Core 2.1, Razor Pages serves as a page any partial view whose file name begins with an underscore. + +::: moniker-end + +::: moniker range="= aspnetcore-2.0 || >= aspnetcore-2.2" + +In ASP.NET Core 2.0 and ASP.NET Core 2.2 or later, Razor Pages doesn't serve the partial view as a page. Don't rely on this behavior as a means to secure the partial views. + +::: moniker-end + +::: moniker range="< aspnetcore-2.0" A partial view is a *.cshtml* markup file maintained within the *Views* folder. From 6e91c3b28d7e6f45e3c24947ca3479eeff25593a Mon Sep 17 00:00:00 2001 From: Scott Addie Date: Wed, 17 Oct 2018 17:24:10 -0500 Subject: [PATCH 2/4] Verbiage tweak --- aspnetcore/mvc/views/partial.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspnetcore/mvc/views/partial.md b/aspnetcore/mvc/views/partial.md index 65bb60bace..f284832680 100644 --- a/aspnetcore/mvc/views/partial.md +++ b/aspnetcore/mvc/views/partial.md @@ -52,7 +52,7 @@ Partial view file names often begin with an underscore (`_`). This naming conven ::: moniker range="= aspnetcore-2.1" -In ASP.NET Core 2.1, Razor Pages serves as a page any partial view whose file name begins with an underscore. +In ASP.NET Core 2.1 only, Razor Pages serves as a page any partial view whose file name begins with an underscore. ::: moniker-end From 00b6296b45485e0e4e872d099e167c1c9620cb67 Mon Sep 17 00:00:00 2001 From: Scott Addie Date: Wed, 17 Oct 2018 19:35:19 -0500 Subject: [PATCH 3/4] React to feedback --- aspnetcore/mvc/views/partial.md | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/aspnetcore/mvc/views/partial.md b/aspnetcore/mvc/views/partial.md index f284832680..54ba9d9b5f 100644 --- a/aspnetcore/mvc/views/partial.md +++ b/aspnetcore/mvc/views/partial.md @@ -48,17 +48,7 @@ Unlike MVC view or page rendering, a partial view doesn't run *_ViewStart.cshtml Partial view file names often begin with an underscore (`_`). This naming convention isn't required, but it helps to visually differentiate partial views from views and pages. -::: moniker-end - -::: moniker range="= aspnetcore-2.1" - -In ASP.NET Core 2.1 only, Razor Pages serves as a page any partial view whose file name begins with an underscore. - -::: moniker-end - -::: moniker range="= aspnetcore-2.0 || >= aspnetcore-2.2" - -In ASP.NET Core 2.0 and ASP.NET Core 2.2 or later, Razor Pages doesn't serve the partial view as a page. Don't rely on this behavior as a means to secure the partial views. +Razor Pages doesn't serve as a page a partial view whose file name begins with an underscore. Don't rely on this behavior as a means to secure a partial view. ::: moniker-end From 4a56fc9fe18dc0c7814eba08eeea939a7b66fbab Mon Sep 17 00:00:00 2001 From: Scott Addie Date: Wed, 17 Oct 2018 19:39:56 -0500 Subject: [PATCH 4/4] Add another sentence about @page --- aspnetcore/mvc/views/partial.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspnetcore/mvc/views/partial.md b/aspnetcore/mvc/views/partial.md index 54ba9d9b5f..9f25994e00 100644 --- a/aspnetcore/mvc/views/partial.md +++ b/aspnetcore/mvc/views/partial.md @@ -48,7 +48,7 @@ Unlike MVC view or page rendering, a partial view doesn't run *_ViewStart.cshtml Partial view file names often begin with an underscore (`_`). This naming convention isn't required, but it helps to visually differentiate partial views from views and pages. -Razor Pages doesn't serve as a page a partial view whose file name begins with an underscore. Don't rely on this behavior as a means to secure a partial view. +Razor Pages doesn't serve as a page a partial view whose file name begins with an underscore. The inclusion of a `@page` directive in the partial view's markup doesn't change this behavior. Don't rely on this behavior as a means to secure a partial view. ::: moniker-end