views:

32

answers:

2

Say there's HomeController with an Details-action. return View() will send data to the Detals.aspx in the Home folder. But who makes that binding? and what if I want it to go to Edit.aspx instead?

Background: Alot of the code in Details.aspx and Edit.aspx is identical, save for one textbox. Maybe by MVC rigor, the view is not supposed to make that kind of decisions, but hey, there's got to be a limit.

+2  A: 

If you want to Edit.aspx to be rendered you could return View("Edit");

Darin Dimitrov
ok :) that was easy! I'm giving it to womp since he/she's 9.9k behind you in rep but only 3 seconds in time.
Martin
+2  A: 

You can make it go to Edit.aspx by specifying it as a parameter of the View() function.

return View("Edit");

As to who makes the actual binding happen, it's the View Engine. It receives the returned ViewResult and analyzes it to see which template file to load and display. When it gets the string "Edit", it runs a find routine, using the context of the controller, to search a number of directories for filenames that match the convention. It starts in the controller's View directory, and then searches the Shared directory.

womp