1

I would like to modify the ASP MVC default view name associated to a controller action method.

Here is my Controller

public class HomeController : Controller
{
    public ActionResult Index()
    {
        return View();
    }
}

As the View() method called without viewName parameter the MVC framwork will look for the view Views/Home/Index.cshtml (and similars)

What I would like to achieve is to look for Views/ThemeA/Home/Index.cshtml or Views/ThemeB/Home/Index.cshtml depending on a global setting.

Please do not recommend me to pass the view name as parameter. The whole point is to be transparent to the Controllers.

Thx in advance

2
  • Maybe this post can help you stackoverflow.com/questions/8820315/… Commented Feb 1, 2014 at 11:27
  • I don't think so... My question nothing to do with the routing. Thx anyway Commented Feb 1, 2014 at 11:37

1 Answer 1

1

Write you own ViewEngine:

http://theshravan.net/blog/configure-the-views-search-locations-in-asp-net-mvc/

Don´tbe scared, just inherit from the standard engine and extend the search locations...

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.