0

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.

Cœur
  • 34,719
  • 24
  • 185
  • 251
Nikola Sivkov
  • 2,804
  • 3
  • 34
  • 63

2 Answers2

2

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.

Darin Dimitrov
  • 994,864
  • 265
  • 3,241
  • 2,902
  • I need this because i need my views in a common location between different web servers. and +1 for RazorEngine, I forgot about it. – Nikola Sivkov Jun 16 '13 at 16:27
0

The best way to do this is to have your Views Precompiled into a dll which can be used across multiple locations with only one code base.

This can be done using the Razor Generator Plugin which you can find here:

http://razorgenerator.codeplex.com/

AntSpiteri
  • 312
  • 1
  • 9