0

i am new in mvc.i created one mvc project in VS2013. so just seen the home controller code and saw there are few action function like

public ActionResult About()
        {
            ViewBag.Message = "Your app description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }

when contact or about action will be called then how asp.net mvc engine will understand which view need to show? and from where to load the view file because view file could be in different folder too.

if i need to show view file in different folder then how could i specify in view() function ? do i need to specify the view path ? or i can give any view name in view function which can load view file from other folder.

when few view file is in same folder then we do not need to specify path? can we specify view name only if view name is not same as action method name.

suppose my view file name is MyAbout.cshtml. so when about action will be called then i can specify name only not path like below

public ActionResult About()
{
      ViewBag.Message = "Your app description page.";
      return View("MyAbout");
}

thanks

Mou
  • 15,673
  • 43
  • 156
  • 275
  • MVC uses conventions, but you can specify alternative folder locations to be searched as discussed in the answers to [this question](http://stackoverflow.com/questions/632964/can-i-specify-a-custom-location-to-search-for-views-in-asp-net-mvc). You can also specify the full path as per [this answer](http://stackoverflow.com/questions/18490741/returning-view-via-a-path-name) –  Aug 26 '15 at 11:44
  • check this article of me, this may help : http://developmentpassion.blogspot.com/2014/10/aspnet-mvc-adding-custom-direcotry-for.html – Ehsan Sajjad Aug 27 '15 at 04:50

0 Answers0