Razor Layout from another assembly

别等时光非礼了梦想. 提交于 2019-12-04 03:49:03

问题


Is it possible to use a layout from another assembly? I spitted up my application in different layers and have a separated UI layer which contains the master layout for the designers to edit.

Is it possible and what I what would my reference looks like?

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

回答1:


You may take a look at the following article which illustrates a technique allowing you to have Razor views embedded into a separate assembly.




回答2:


At the end by the time you run the website, you need to gather all the views including layouts to a known place.

In this case you can copy the shared views under root

<siteroot>/Views/Shared/

With this assumption you can refer these layouts the way you are doing. However visual studio or tools like resharper keep showing this as an error. You need to get comfortable with those errors.



来源:https://stackoverflow.com/questions/9047368/razor-layout-from-another-assembly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!