Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在mylayout.cshtml中调用页脚部分?_C#_Asp.net Mvc - Fatal编程技术网

C# 如何在mylayout.cshtml中调用页脚部分?

C# 如何在mylayout.cshtml中调用页脚部分?,c#,asp.net-mvc,C#,Asp.net Mvc,我在做模板集成。 首先,创建一个控制器HomeController,然后创建一个方法 家庭控制器 public ActionResult Footer() //I create an Individual View from footer { return View(); } Footer.cshtml @section footer { <footer class="footer-area"> <div class="container">

我在做模板集成。 首先,创建一个控制器HomeController,然后创建一个方法

家庭控制器

public ActionResult Footer()  //I create an Individual View from footer
{
   return View();
}
Footer.cshtml

@section footer
{
  <footer class="footer-area">
        <div class="container">
            <div class="row">
               //about us contax us
             </div>
     </div>
    </footer>
}

sharedfolder->create(mylayout.cshtml)
mylayout.cshtml

    <!-- banner post start-->
    <div>
        @RenderBody();      //Dynamic Content
    </div>

    <!-- banner post end-->

    <!-- footer part start-->
      @RenderSection("footer") //error: Section not defined: "footer".
    <!-- footer part end-->

@节页脚
{
//关于我们
}
sharedfolder->create(mylayout.cshtml)
mylayout.cshtml
@RenderBody()//动态内容
@RenderSection(“页脚”)//错误:未定义节:“页脚”。

创建一个局部视图
“\u footer.cshtml”
并在该局部视图中添加代码

然后在布局页面中呈现页脚部分视图,如下所示:

@Html.RenderPartial("_footer.cshtml")
@Html.Action(“页脚”、“主页”)
在布局中
并且您的foooter.cshtml必须是部分视图。

MVC给出一个错误:无法从'void'转换为'System.Web.WebPages.HelperResult'Use@Html.Render(“\u footer.cshtml”)@Nhein
Footers将在@section footer{//not run content inside}中运行页眉标记
尝试删除@section just Use-Use-thank works。局部视图是空白/空视图。这是为模板使用单个局部视图的最佳方式integration@Nhein这是使用单个局部视图进行模板集成的最佳方式吗?