Quantcast
Channel: RazorGenerator Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 525

Commented Unassigned: Customized view location [156]

$
0
0
After using Razor generator, MVC cannot find views in customized location if they are from a library.

For example:

public ActionResult Index()
{
// this works perfect
// return View("~/Views/CustomizedLocation/foo/baz.cshtml");

// this does not work
return View("~/Views/CustomizedLocation/foo/bar.cshtml");
}

See sample project:
- "bar.cshtml" is from a lib, whereas "baz.cshtml" is in the web app itself.
- I do NOT want to register "CustomizedLocation" in the view finder for many reasons. I only want to pick it up when needed.

Should be a simple problem but I could not find any existing discussions. Sorry if dup.
Comments: Thanks David that is the key --- "register the Library as a view engine". Turned out that every single DLL that has view in it should be registered such as: public static void AddViewEngineForAssembly(Assembly dll) { var engine = new PrecompiledMvcEngine(dll); ViewEngines.Engines.Add(engine); // StartPage lookups are done by WebPages. VirtualPathFactoryManager.RegisterVirtualPathFactory(engine); } if you have N such libraries, you will need N PrecompiledMvcEngine(s).

Viewing all articles
Browse latest Browse all 525

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>