Search code examples
asp.netasp.net-mvc-3razorviewengine

How to use a Partial from a UNC Path?


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?


Solution

  • You could try writing a custom virtual path provider.