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.

1 Answer 1

3
return View("DisplayPerson", prn)

or

return View("PersonView2", prn)

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

Sign up to request clarification or add additional context in comments.

1 Comment

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.