Search code examples
c#asp.net-mvcasp.net-mvc-4razor-2

Load views from location outside the mvc website


I'm trying to load an MVC view form a folder outside the location of the app.

My app is in C:\dev\myproject\ and the view file i'm trying to load is located in D:\viewsfolder\something is it possible to do that?

I tried passing an absolute path to the return View() method but that didn't work.


Solution

  • This is not supported by standard ASP.NET MVC. You may take a look at the RazorEngine plugin which allows you to render a Razor view from a string.

    You haven't really explained why you need to do that by the way. Maybe there's a better approach to your particular problem.