简体   繁体   中英

ASP.NET MVC : Calling Different View

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 = "Jass@yahoo.com";
        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.

return View("DisplayPerson", prn)

or

return View("PersonView2", prn)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM