【发布时间】:2009-04-27 14:55:50
【问题描述】:
为了让多个站点拥有一组中心视图,我创建了一个包含我的视图的外部库。它们被标记为内容并始终复制。
这个视图库在我的网站中被引用,因此通过编译在他们的 bin 文件夹中获得一个“视图”文件夹。
然后我制作了一个这样的快速自定义 ViewEngine:
public class CommonViewLocator: WebFormViewEngine
{
public CommonViewLocator()
{
MasterLocationFormats = new[] {
"~/bin/Views/{1}/{0}.master",
"~/bin/Views/Shared/{0}.master"
};
ViewLocationFormats = new[] {
"~/bin/Views/{1}/{0}.aspx",
"~/bin/Views/{1}/{0}.ascx",
"~/bin/Views/Shared/{0}.aspx",
"~/bin/Views/Shared/{0}.ascx"
};
PartialViewLocationFormats = ViewLocationFormats;
}
}
运行后我得到这个屏幕:
The view 'Index' or its master could not be found. The following locations were searched:
~/Views/Home/Index.aspx
~/Views/Home/Index.ascx
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx
~/bin/Views/Home/Index.aspx
~/bin/Views/Home/Index.ascx
~/bin/Views/Shared/Index.aspx
~/bin/Views/Shared/Index.ascx
出了什么问题?
另外,bin文件夹有view感觉有点奇怪,欢迎提出其他建议。
【问题讨论】:
标签: c# .net asp.net-mvc