I created an ASP.NET MVC 5 project where I had made a template , so now we will have several templates divided by areas . But the controllers will be the same, so I did not want to create the same controllers for all areas . How do I do this?
//exemplo link html
<a href='/home/index'> Home </a>
//controller:
public ActionResult Index(){
//aqui faço a verificação que retornará a area
string retorno = obterAreaUtilizada(); //ex.:"template02"
return RedirectToAction("Index","Home", new { area = retorno });
}
But I'm testing here and it's giving me error, for not just using controller in the areas ... could anyone help me?
EDIT
I found a way, but I need to know if it's consistent, not a gambiarra:
public ActionResult Index(){
//aqui faço a verificação que retornará a area
string retorno = obterAreaUtilizada(); //ex.:"template02"
string caminho = string.format("~/areas/{0}/views/home/index.cshtml",retorno);
return View(caminho);
}
Please, if anyone knows a better solution, it would be great if you shared it. Many thanks.