开发者

How to use a Partial from a UNC Path?

开发者 https://www.devze.com 2023-02-25 16:18 出处:网络
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 parti

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 vie开发者_JAVA百科w.

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?


You could try writing a custom virtual path provider.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号