简体   繁体   English

共享版面优先

[英]Shared layout priority

I have _layout1.cshtml in Areas/Book/Views/Shared/_layout1.cshtml and in /Views/Shared/_layout.cshtml . 我已经_layout1.cshtmlAreas/Book/Views/Shared/_layout1.cshtml/Views/Shared/_layout.cshtml

Areas/Book/Views/Home/Index.cshmtl: 区域/书籍/视图/首页/Index.cshmtl:

@{
    Layout = "~/Areas/Book/Views/Shared/_layout1.cshtml";    
}

Somehow it stills show the content of _layout1 in Root /Views/Shared instead of in the Areas/Book 它仍然以_layout1在“根” /Views/Shared而不是在“ Areas/Book显示_layout1的内容

Is there any priority when the layout view share the same name? 布局视图共享相同的名称时,是否有优先级?

The code as you posted it here should work. 您在此处发布的代码应该可以正常工作。 I am using the same successfully here. 我在这里成功地使用了同样的东西。

Make shure the path is correct and the layout file is where you say it is. 确保路径正确,并且布局文件就是您所说的位置。

Maybe odd, but what could cause this if the file is there: 可能很奇怪,但是如果文件存在,可能会导致以下问题:
If your APP is running with a differen user which does not have access rights to the file it could happen that the file "is not there" for the app. 如果您的APP是与没有该文件访问权限的其他用户一起运行的,则可能发生该文件“不存在”的情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM