tags:

views:

49

answers:

1

I have a controller located in Controllers folder.

Controllers
          .... CustomViewController

The CustomViewController executes the following method

 public ActionResult DisplayPerson()
    {
        Person prn = new Person();
        prn.Name = "Rama";
        prn.Email = "[email protected]";
        return View(prn);
    }

I have two views located in CustomView folder

Views
     ....CustomView
         .. DisplayPerson
         .. PersonView2

Routing

routes.MapRoute(
                  "Display",
                  "{Controller}/{action}/{id}",
                   new { controller = "CustomView", 
                   action = "DisplayPerson", id = "" }
               );

Question :

By default the view "DisplayPerson" is used to display the Person details.What is the way to call the view "PersonView2" inside the "DisplayPerson()" method.

+2  A: 
return View("DisplayPerson", prn)

or

return View("PersonView2", prn)

http://msdn.microsoft.com/en-us/library/dd460310.aspx

Brannon
If you don't give a view name, MVC defaults to a view named for the Action, but this is just a *default*.
Richard