From dd08c26fe0c906d011d49779db8e5abb9fb4edb5 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Thu, 17 Jan 2019 13:53:42 +0300 Subject: [PATCH] #739 Added UseMvcWithDefaultRouteAndArea extension method. --- ...pNetCoreMvcApplicationBuilderExtensions.cs | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc/Microsoft/AspNetCore/Builder/AbpAspNetCoreMvcApplicationBuilderExtensions.cs diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Microsoft/AspNetCore/Builder/AbpAspNetCoreMvcApplicationBuilderExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Microsoft/AspNetCore/Builder/AbpAspNetCoreMvcApplicationBuilderExtensions.cs new file mode 100644 index 0000000000..8b1f6e9d49 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Microsoft/AspNetCore/Builder/AbpAspNetCoreMvcApplicationBuilderExtensions.cs @@ -0,0 +1,36 @@ +using System; +using Microsoft.AspNetCore.Routing; + +namespace Microsoft.AspNetCore.Builder +{ + public static class AbpAspNetCoreMvcApplicationBuilderExtensions + { + /// + /// Adds MVC to the request execution pipeline + /// with the following default routes: + /// + /// - a default route named 'defaultWithArea' and the following template: '{area}/{controller=Home}/{action=Index}/{id?}'. + /// - a default route named 'default' and the following template: '{controller=Home}/{action=Index}/{id?}'. + /// + /// The . + /// Additional action to configure routes + /// A reference to this instance after the operation has completed. + public static IApplicationBuilder UseMvcWithDefaultRouteAndArea( + this IApplicationBuilder app, + Action additionalConfigurationAction = null) + { + return app.UseMvc(routes => + { + routes.MapRoute( + name: "defaultWithArea", + template: "{area}/{controller=Home}/{action=Index}/{id?}"); + + routes.MapRoute( + name: "default", + template: "{controller=Home}/{action=Index}/{id?}"); + + additionalConfigurationAction?.Invoke(routes); + }); + } + } +}