HTML.Partial区分大小写吗?

时间:2017-05-19 01:53:28

标签: c# asp.net-mvc razor

HTML.Partial区分大小写吗?如果是,当我没有正确的大写时,如何调用部分?

1 个答案:

答案 0 :(得分:1)

否Html.partial()不区分大小写。我测试了它。

例如:

假设您的部分视图名称为“_HeaDing.cshtml”,并且它位于同一文件夹中。

然后在不同情况下调用部分视图,如下所示:

1.  @Html.Partial("_heading")-All characters are in smaller case
2.  @Html.Partial("_HEADING")- All characters are in Upper case

在所有组合情况下,它都可以通过调用同一个文件来正常工作。

其他信息:

要调用不同文件夹或不同路径中的视图,请遵循以下语法:

// Uses a view in current folder with this name
// If none is found, searches the Shared folder
@Html.Partial("ViewName")

// A view with this name must be in the same folder
@Html.Partial("ViewName.cshtml")

// Locate the view based on the application root
// Paths that start with "/" or "~/" refer to the application root
@Html.Partial("~/Views/Folder/ViewName.cshtml")
@Html.Partial("/Views/Folder/ViewName.cshtml")

// Locate the view using relative paths
@Html.Partial("../Account/LoginPartial.cshtml")

来源: https://docs.microsoft.com/en-us/aspnet/core/mvc/views/partial

希望这对您有所帮助,请告诉我您的想法或反馈

由于

KARTHIK