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); + }); + } + } +}