29.05.2015 Views

o_19mgorv9t13a3ko71fev19l81mqa.pdf

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Figure 2-9. The MVC Framework trying to find a default view<br />

This error message is quite helpful. It explains not only that MVC could not find a view for the action method, but it shows<br />

where it looked. This is another nice illustration of an MVC convention: views are associated with action methods by a naming<br />

convention. The action method is called Index and the controller is called Home and you can see from Figure 2-9 that MVC is<br />

trying to find different files in the Views folder that have that name.<br />

The simplest way to create a view is to ask Visual Studio to do it for you. Right-click anywhere in the definition of the Index<br />

action method in code editor window for the HomeController.cs file and select Add View from the pop-up menu,<br />

as shown in Figure 2-10.<br />

38

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!