Generating Outgoing URLs

Routes are more important in an MVC framework application than in a Web Forms application because we are intimately engaged in the HTML that our application generates. To that end, there are a set of helper methods that we can use in views to generate URLs from the routing system. The simplest way to generate an outgoing URL in a view is to call the Html.ActionLink helper. Listing 27-6 shows this helper used in the List.cshtml view of the Registration controller.

Listing 27-6. Calling the ActionLink helper

@model IEnumerable<EventRegistration.Models.Domain.Registration> @using EventRegistration.Infrastructure @{     ViewBag.Title = "List";     Layout = "~/Views/Shared/CustomLayout.cshtml"; } @Html.RegistrationCount(@Model.Count()) ...

Get Applied ASP.NET 4 in Context now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.