【问题标题】:Is HTML.Partial case sensitive? [closed]HTML.Partial 区分大小写吗? [关闭]
【发布时间】:2017-10-19 00:06:36
【问题描述】:

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

【问题讨论】:

  • 这是 Html.Partial,但不清楚你在问什么。

标签: c# asp.net-mvc razor


【解决方案1】:

No 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

希望对您有所帮助,请让我知道您的想法或反馈

谢谢

卡提克

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-17
    • 1970-01-01
    • 2013-03-28
    • 1970-01-01
    • 1970-01-01
    • 2012-12-20
    相关资源
    最近更新 更多