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 16-11. Requesting a static content URL which is handled by the routing system<br />

Defining Routes for Disk Files<br />

Once the property has been set to true, I can define routes that match URLs that correspond to disk files, such as the one<br />

shown in Listing 16-33.<br />

Listing 16-33. A Route Whose URL Pattern Corresponds to a Disk File in the RouteConfig.cs File<br />

using System.Web.Mvc;<br />

using System.Web.Routing;<br />

using UrlsAndRoutes.Infrastructure;<br />

namespace UrlsAndRoutes {<br />

public class RouteConfig {<br />

public static void RegisterRoutes(RouteCollection routes) {<br />

routes.RouteExistingFiles = true;<br />

routes.MapMvcAttributeRoutes();<br />

routes.MapRoute("DiskFile", "Content/StaticContent.html",<br />

new {<br />

controller = "Customer",<br />

action = "List",<br />

});<br />

429

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

Saved successfully!

Ooh no, something went wrong!