using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace Transaction.Site.Models
{
public class MyViewEngine : RazorViewEngine
{
protected override IView CreateView (ControllerContext controllerContext, string viewPath, string masterPath)
{
var ck = controllerContext.HttpContext.Request.Cookies.Get("p_lang" );
string lg = "" ;
if (ck != null )
{
lg = ck.Value;
if (lg.ToLower() == "en" )
{
viewPath = viewPath.Replace("Views" , "Views/en" );
}
}
return base .CreateView(controllerContext, viewPath, masterPath);
}
protected override IView CreatePartialView (ControllerContext controllerContext, string partialPath)
{
var ck = controllerContext.HttpContext.Request.Cookies.Get("p_lang" );
string lg = "" ;
if (ck != null )
{
lg = ck.Value;
if (lg.ToLower() == "en" )
{
partialPath = partialPath.Replace("Views" , "Views/en" );
}
}
return base .CreatePartialView(controllerContext, partialPath);
}
}
}
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start ()
{
ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new MyViewEngine());
}
}