Say I have a controller with these action methods:
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult About()
{
return View();
}
public ActionResult Contact()
{
return View();
}
}
By convention I'll have three views having the same name of the methods.
But what if I want to add prefix to the view name? For example, in my case I'd like to add Controller name as prefix to the view name, so I'll have: HomeIndex
, HomeAbout
, HomeContact
. Is there a way to obtain this by a configuration or do I have to explicitly pass the name for every View()
?
NOTE I don't want to rename my action methods to
HomeIndex()
HomeAbout()
- etc.
because I want to maintain URLs in the common format:
/Home/Index
/Home/About
I just want a different naming convention for my cshtml
files, possibly without explicitly need to specify the name in View
method.