如何使用 UNC 路径中的部分内容?
我正在尝试使用 UNC 路径中的部分内容。我已经扩展了 RazorViewEngine 以包含路径,并正确注册。当我加载视图时,它显示我已包含正确列出的部分名称的路径,但仍然显示它无法加载视图。
相关代码:
public class MobileViewEngine : RazorViewEngine
{
public MobileViewEngine()
{
var viewLocations = new[] {
"\\uncserver\views\{0}.cshtml"
};
this.PartialViewLocationFormats = viewLocations;
this.ViewLocationFormats = viewLocations;
}
}
链接到部分的 Razor 模板:
@Html.Partial("12\\1\\1.tpl")
错误:
部分视图“12\1\1.tpl”不是 发现或没有视图引擎支持 搜索过的地点。下列 搜索地点: \\uncserver\views\12\1\1.tpl.cshtml
如果我访问它说找不到视图的路径,则视图就在那里。 IIS 正在正确的权限下运行以查看此 unc 路径。
有什么想法吗?
I'm trying to use partials from a UNC path. I've extended the RazorViewEngine to include the path, and registered properly. When I load the view, it shows that path that I have included with the partial name correctly listed, but still shows it can't load the view.
Relevant code:
public class MobileViewEngine : RazorViewEngine
{
public MobileViewEngine()
{
var viewLocations = new[] {
"\\uncserver\views\{0}.cshtml"
};
this.PartialViewLocationFormats = viewLocations;
this.ViewLocationFormats = viewLocations;
}
}
The Razor template linking to the partial:
@Html.Partial("12\\1\\1.tpl")
The error:
The partial view '12\1\1.tpl' was not
found or no view engine supports the
searched locations. The following
locations were searched:
\\uncserver\views\12\1\1.tpl.cshtml
If I visit the path it says it didn't find the view at, the view is there. IIS is running under correct permissions for viewing this unc path.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试编写自定义虚拟路径提供程序。
You could try writing a custom virtual path provider.