I want to change view locations at runtime based on current UI culture. How can I achieve this with default Web Form view engine?
Basically I want to know how implem
I believe that solution would be to create your own ViewEngine which inherits from WebFormViewEngine. In constructor, it should check current UI culture from current thread and add appropriate locations. Just don't forget to add it to your view engines.
This should look something like this:
public class ViewEngine : WebFormViewEngine
{
public ViewEngine()
{
if (CultureIsX())
ViewLocationFormats = new string[]{"route1/controller.aspx"};
if (CultureIsY())
ViewLocationFormats = new string[]{"route2/controller.aspx"};
}
}
in global.asax:
ViewEngines.Engines.Add(new ViewEngine());