From 53f3a91f01c740f3cbf5209a9eeeefd614a6cbc2 Mon Sep 17 00:00:00 2001 From: Henk Mollema Date: Mon, 20 Apr 2015 19:28:11 +0200 Subject: [PATCH] Added UseMvcWithDefaultRoute extension to BuilderExtensions Added `UseMvcWithDefaultRoute` extension method to `BuilderExtensions`, which adds Mvc to the request pipeline with a default route to the `Index` action on the `HomeController`. #1885 --- src/Microsoft.AspNet.Mvc/BuilderExtensions.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Microsoft.AspNet.Mvc/BuilderExtensions.cs b/src/Microsoft.AspNet.Mvc/BuilderExtensions.cs index 5f24c2781a..d33436a798 100644 --- a/src/Microsoft.AspNet.Mvc/BuilderExtensions.cs +++ b/src/Microsoft.AspNet.Mvc/BuilderExtensions.cs @@ -29,6 +29,22 @@ namespace Microsoft.AspNet.Builder }); } + /// + /// Adds Mvc to the request execution pipeline + /// with a default route. + /// + /// The . + /// The . + public static IApplicationBuilder UseMvcWithDefaultRoute([NotNull] this IApplicationBuilder app) + { + return app.UseMvc(routes => + { + routes.MapRoute( + name: "default", + template: "{controller=Home}/{action=Index}/{id?}"); + }); + } + /// /// Adds Mvc to the request execution pipeline. ///