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
This commit is contained in:
Henk Mollema 2015-04-20 19:28:11 +02:00 committed by Ajay Bhargav Baaskaran
parent 3ea7daabfe
commit 53f3a91f01
1 changed files with 16 additions and 0 deletions

View File

@ -29,6 +29,22 @@ namespace Microsoft.AspNet.Builder
});
}
/// <summary>
/// Adds Mvc to the <see cref="IApplicationBuilder"/> request execution pipeline
/// with a default route.
/// </summary>
/// <param name="app">The <see cref="IApplicationBuilder"/>.</param>
/// <returns>The <paramref name="app"/>.</returns>
public static IApplicationBuilder UseMvcWithDefaultRoute([NotNull] this IApplicationBuilder app)
{
return app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
/// <summary>
/// Adds Mvc to the <see cref="IApplicationBuilder"/> request execution pipeline.
/// </summary>