2011-04-12 101 views
0

我试图使用UNC路径中的部分。我已经扩展了RazorViewEngine以包含路径并正确注册。当我加载视图时,它显示我包含的部分名称正确列出的路径,但仍显示它无法加载视图。如何从UNC路径使用部分?

相关代码:


    public class MobileViewEngine : RazorViewEngine 
    { 
     public MobileViewEngine() 
     { 
      var viewLocations = new[] { 
      "\\uncserver\views\{0}.cshtml" 
     }; 

      this.PartialViewLocationFormats = viewLocations; 
      this.ViewLocationFormats = viewLocations; 
     } 
    } 

剃刀模板链接部分:

@Html.Partial("12\\1\\1.tpl") 

错误:

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

如果我访问路径它说,它没有找到视图,视图就在那里。 IIS正在以正确的权限运行,以查看此unc路径。

任何想法?

回答

1

您可以尝试编写一个custom virtual path provider

+0

这看起来应该起作用。谢谢! – Case 2011-04-14 04:29:03

+0

我刚刚实现了这一点,它确实有效。该页面上的示例代码对我来说有点稀疏,但我能够正确地工作。 – Case 2011-05-28 01:32:52