I have a page which consists of multiple partial views uploaded by a user. I have customized the Razor viewEngine to look at different locations for the .cshtml files. Now if i'm rendering a partial view _abc.cshtml(found on my external location) and this partial view requires a viewmodel AbcViewModel, whats the best way to deal with this?
- option 1: I have a DB entry that specifies
_abc.cshtml
uses AbcViewModel. So once I find the partial view, i'll know which viewmodel to use..In this case the ViewModel resides in the solution itself.
Using reflection I can get the class
Assembly assembly = Assembly.GetExecutingAssembly();
AbcViewModel viewModel= assembly.CreateInstance("AbcViewModel") as AbcViewModel;
I was wondering if there is a way that I could have the viewModel at an external location..this way I can extend my application..