0

I want to manipulate the view that eventually MVC is going to render at run time.

For example at HomeConttroller I do this:

public ActionResult Index()
{
     return View();
}

asp.net mvc has decided to render ~/Views/Home/Index.cshtml i want to change it to something like "~/en/Views/Homem/Index.cshtml". update: i do`not want to use the View(string path) overload.

i mean i want to change the path at the last moment. this question is not a duplicate so please dont vote for closing when you havent undertand the question ... pff

SHM
  • 1,896
  • 19
  • 48
  • possible duplicate of [ASP.NET MVC How to specify which folder the View pages reside in?](http://stackoverflow.com/questions/799838/asp-net-mvc-how-to-specify-which-folder-the-view-pages-reside-in) – Christos Jan 31 '15 at 07:39
  • check this post: http://stackoverflow.com/questions/26575397/is-it-possible-to-have-multiple-shared-folders-in-mvc-and-execute-a-renderparti and also this: http://developmentpassion.blogspot.com/2014/10/aspnet-mvc-adding-custom-direcotry-for.html – Ehsan Sajjad Jan 31 '15 at 07:49
  • possible duplicate of [Is it possible to have multiple Shared folders in MVC, and execute a RenderPartial to a Partial View in the other shared folder?](http://stackoverflow.com/questions/26575397/is-it-possible-to-have-multiple-shared-folders-in-mvc-and-execute-a-renderparti) – Ehsan Sajjad Jan 31 '15 at 07:52

1 Answers1

0

I want to change it at run time to some thing like ~/Views/en/Home/Index.cshtml. Is this possible?

Sure, you can specify the view to be rendered using this overload:

public ActionResult Index()
{
     return View("~/Views/en/Home/Index.cshtml");
}
Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928