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.

}<br />

return "This is the Index action on the Home controller";<br />

}<br />

}<br />

[GoogleAuth]<br />

[Authorize(Users = "bob@google.com")]<br />

public string List() {<br />

return "This is the List action on the Home controller";<br />

}<br />

public string RangeTest(int id) {<br />

if (id > 100) {<br />

return String.Format("The id value is: {0}", id);<br />

} else {<br />

throw new ArgumentOutOfRangeException("id", id, "");<br />

}<br />

}<br />

You can see the default exception handling if you start the application and navigate to the /Home/RangeTest/50 URL.<br />

The default routing that Visual Studio creates for an MVC project has a segment variable called id which will be set to 50 for<br />

this URL, triggering the response shown in Figure 18-3. (See Chapters 15 and 16 for details of routing and URL segments.)<br />

477

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

Saved successfully!

Ooh no, something went wrong!