I think anybody wowould have the same problem as my that have a little big MVC project and Of couse we have alot views to share, its necessary for reuse, but sadlly our mvc3 razor view only provide one share Dir of "share ".
If you type viewengin in zzk, you will c most results are tell you to create a new view engine, its too complex to only add a share directory.
So my solution is to modify the ve, firstly you shoshould know, its init two default viewengine:
StaticViewengines ()
{
Viewenginecollection engines =NewViewenginecollection ();
Engines. Add (NewWebformviewengine ());
Engines. Add (NewRazorviewengine ());
_ Engines = engines;
}
My code (because no aspx or other webforms need in my website so no webform ve needed !)
Viewengines. Engines. Clear ();
VaR RVE =NewRazorviewengine ();
VaR newloactions = RVE. partialviewlocationformats. tolist ();
Newloactions. addrange (NewList <String>
{
//"~ /Views/{Controller: 1}/{0}. cshtml"
"~ /Views/XXX/{0}. cshtml"
});
RVE. partialviewlocationformats = newloactions. toarray ();
Viewengines. Engines. Add (RVE );
Hope can help you too!