Search code examples
asp.net-mvc-2stringembedded-resource

How to handle actions and views names in my ASP.NET MVC application?


I have an ASP.NET MVC applications and i don't want to explicitly write the actions or the views names like this :

return RedirectToAction("Index"); or return View("Home");

what is the best practice for handling those strings?

I use Visual Studio 2010 and ASP.NET MVC2


Solution

  • There's MVCContrib and inside there are extension methods allowing you to write:

    return RedirectToAction<HomeController>(x => x.About());
    

    Another possibility is T4 templates.