I am implementing custom CustomRazorViewEngine based on current domain name I want to look to specific view folder.

if (System.Web.HttpContext.Current.Request.Url.Host == "somehost")
                viewFolder = "Site1";
                viewFolder = "Site2";

base.AreaViewLocationFormats = new string[] 
                "~/Areas/{2}/Views/" + viewFolder + "/{1}/{0}.cshtml", 
                "~/Areas/{2}/Views/" + viewFolder + "/{1}/{0}.vbhtml", 
                "~/Areas/{2}/Views/" + viewFolder + "/Shared/{0}.cshtml", 
                "~/Areas/{2}/Views/" + viewFolder + "/Shared/{0}.vbhtml" 

But current request is not avaliable at this time so System.Web.HttpContext.Current.Request.Url.Host throwing the exeption "Request is not avaliable at this context" Do you have any idea how to do it best?

Related posts

Recent Viewed