Browse Source

use file-scoped namespacing for app template

pull/10696/head
Ahmet Çotur 5 years ago
parent
commit
ab6c9ddd63
  1. 31
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/MyProjectNameApplicationContractsModule.cs
  2. 19
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/MyProjectNameDtoExtensions.cs
  3. 23
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/Permissions/MyProjectNamePermissionDefinitionProvider.cs
  4. 15
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/Permissions/MyProjectNamePermissions.cs
  5. 15
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application/MyProjectNameAppService.cs
  6. 15
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application/MyProjectNameApplicationAutoMapperProfile.cs
  7. 35
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application/MyProjectNameApplicationModule.cs
  8. 11
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Components/Toolbar/LoginLink/LoginLinkViewComponent.cs
  9. 9
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Controllers/AccountController.cs
  10. 103
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Menus/MyProjectNameMenuContributor.cs
  11. 15
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Menus/MyProjectNameMenus.cs
  12. 25
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Menus/MyProjectNameToolbarContributor.cs
  13. 443
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/MyProjectNameBlazorModule.cs
  14. 11
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/MyProjectNameBrandingProvider.cs
  15. 11
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/MyProjectNameComponentBase.cs
  16. 7
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Pages/Index.razor.cs
  17. 65
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Program.cs
  18. 19
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Startup.cs
  19. 67
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/Menus/MyProjectNameMenuContributor.cs
  20. 15
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/Menus/MyProjectNameMenus.cs
  21. 383
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/MyProjectNameBlazorModule.cs
  22. 11
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/MyProjectNameBrandingProvider.cs
  23. 11
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/MyProjectNameComponentBase.cs
  24. 7
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/Pages/Index.razor.cs
  25. 65
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/Program.cs
  26. 19
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/Startup.cs
  27. 83
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Menus/MyProjectNameMenuContributor.cs
  28. 15
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Menus/MyProjectNameMenus.cs
  29. 11
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBlazorAutoMapperProfile.cs
  30. 133
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBlazorModule.cs
  31. 11
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBrandingProvider.cs
  32. 25
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBundleContributor.cs
  33. 11
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameComponentBase.cs
  34. 7
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Pages/Index.razor.cs
  35. 25
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Program.cs
  36. 59
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/DbMigratorHostedService.cs
  37. 21
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/MyProjectNameDbMigratorModule.cs
  38. 43
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/Program.cs
  39. 11
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/Localization/MyProjectNameResource.cs
  40. 17
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MultiTenancy/MultiTenancyConsts.cs
  41. 9
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MyProjectNameDomainErrorCodes.cs
  42. 69
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MyProjectNameDomainSharedModule.cs
  43. 17
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MyProjectNameGlobalFeatureConfigurator.cs
  44. 105
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MyProjectNameModuleExtensionConfigurator.cs
  45. 9
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Data/IMyProjectNameDbSchemaMigrator.cs
  46. 297
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Data/MyProjectNameDbMigrationService.cs
  47. 19
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Data/NullMyProjectNameDbSchemaMigrator.cs
  48. 527
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/IdentityServer/IdentityServerDataSeedContributor.cs
  49. 11
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/MyProjectNameConsts.cs
  50. 43
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/MyProjectNameDomainModule.cs
  51. 13
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Settings/MyProjectNameSettingDefinitionProvider.cs
  52. 15
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Settings/MyProjectNameSettings.cs
  53. 43
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/EntityFrameworkCoreMyProjectNameDbSchemaMigrator.cs
  54. 121
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContext.cs
  55. 37
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContextFactory.cs
  56. 21
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameEfCoreEntityExtensionMappings.cs
  57. 55
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreModule.cs
  58. 2583
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20211105125915_Initial.cs
  59. 45
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Client/MyProjectNameHttpApiClientModule.cs
  60. 11
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/Controllers/HomeController.cs
  61. 329
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs
  62. 65
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/Program.cs
  63. 19
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/Startup.cs
  64. 11
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/Controllers/HomeController.cs
  65. 11
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyProjectNameBrandingProvider.cs
  66. 359
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyProjectNameHttpApiHostModule.cs
  67. 65
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/Program.cs
  68. 19
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/Startup.cs
  69. 17
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi/Controllers/MyProjectNameController.cs
  70. 13
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi/Models/Test/TestModel.cs
  71. 49
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi/MyProjectNameHttpApiModule.cs
  72. 11
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameBrandingProvider.cs
  73. 271
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs
  74. 11
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/Pages/Index.cshtml.cs
  75. 65
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/Program.cs
  76. 19
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/Startup.cs
  77. 47
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDb/MongoDbMyProjectNameDbSchemaMigrator.cs
  78. 29
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDb/MyProjectNameMongoDbContext.cs
  79. 45
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDb/MyProjectNameMongoDbModule.cs
  80. 11
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Components/Toolbar/LoginLink/LoginLinkViewComponent.cs
  81. 9
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Controllers/AccountController.cs
  82. 103
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Menus/MyProjectNameMenuContributor.cs
  83. 15
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Menus/MyProjectNameMenus.cs
  84. 25
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Menus/MyProjectNameToolbarContributor.cs
  85. 11
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameBrandingProvider.cs
  86. 11
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebAutoMapperProfile.cs
  87. 355
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebModule.cs
  88. 21
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Pages/Index.cshtml.cs
  89. 13
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Pages/MyProjectNamePageModel.cs
  90. 65
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Program.cs
  91. 19
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Startup.cs
  92. 63
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Menus/MyProjectNameMenuContributor.cs
  93. 15
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Menus/MyProjectNameMenus.cs
  94. 11
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameBrandingProvider.cs
  95. 11
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebAutoMapperProfile.cs
  96. 351
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs
  97. 13
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/Index.cshtml.cs
  98. 17
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/MyProjectNamePageModel.cs
  99. 65
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Program.cs
  100. 19
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Startup.cs

31
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/MyProjectNameApplicationContractsModule.cs

@ -7,23 +7,22 @@ using Volo.Abp.PermissionManagement;
using Volo.Abp.SettingManagement; using Volo.Abp.SettingManagement;
using Volo.Abp.TenantManagement; using Volo.Abp.TenantManagement;
namespace MyCompanyName.MyProjectName namespace MyCompanyName.MyProjectName;
[DependsOn(
typeof(MyProjectNameDomainSharedModule),
typeof(AbpAccountApplicationContractsModule),
typeof(AbpFeatureManagementApplicationContractsModule),
typeof(AbpIdentityApplicationContractsModule),
typeof(AbpPermissionManagementApplicationContractsModule),
typeof(AbpSettingManagementApplicationContractsModule),
typeof(AbpTenantManagementApplicationContractsModule),
typeof(AbpObjectExtendingModule)
)]
public class MyProjectNameApplicationContractsModule : AbpModule
{ {
[DependsOn( public override void PreConfigureServices(ServiceConfigurationContext context)
typeof(MyProjectNameDomainSharedModule),
typeof(AbpAccountApplicationContractsModule),
typeof(AbpFeatureManagementApplicationContractsModule),
typeof(AbpIdentityApplicationContractsModule),
typeof(AbpPermissionManagementApplicationContractsModule),
typeof(AbpSettingManagementApplicationContractsModule),
typeof(AbpTenantManagementApplicationContractsModule),
typeof(AbpObjectExtendingModule)
)]
public class MyProjectNameApplicationContractsModule : AbpModule
{ {
public override void PreConfigureServices(ServiceConfigurationContext context) MyProjectNameDtoExtensions.Configure();
{
MyProjectNameDtoExtensions.Configure();
}
} }
} }

19
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/MyProjectNameDtoExtensions.cs

@ -2,16 +2,16 @@
using Volo.Abp.ObjectExtending; using Volo.Abp.ObjectExtending;
using Volo.Abp.Threading; using Volo.Abp.Threading;
namespace MyCompanyName.MyProjectName namespace MyCompanyName.MyProjectName;
public static class MyProjectNameDtoExtensions
{ {
public static class MyProjectNameDtoExtensions private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner();
{
private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner();
public static void Configure() public static void Configure()
{
OneTimeRunner.Run(() =>
{ {
OneTimeRunner.Run(() =>
{
/* You can add extension properties to DTOs /* You can add extension properties to DTOs
* defined in the depended modules. * defined in the depended modules.
* *
@ -23,7 +23,6 @@ namespace MyCompanyName.MyProjectName
* See the documentation for more: * See the documentation for more:
* https://docs.abp.io/en/abp/latest/Object-Extensions * https://docs.abp.io/en/abp/latest/Object-Extensions
*/ */
}); });
}
} }
} }

23
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/Permissions/MyProjectNamePermissionDefinitionProvider.cs

@ -2,20 +2,19 @@
using Volo.Abp.Authorization.Permissions; using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Localization; using Volo.Abp.Localization;
namespace MyCompanyName.MyProjectName.Permissions namespace MyCompanyName.MyProjectName.Permissions;
public class MyProjectNamePermissionDefinitionProvider : PermissionDefinitionProvider
{ {
public class MyProjectNamePermissionDefinitionProvider : PermissionDefinitionProvider public override void Define(IPermissionDefinitionContext context)
{ {
public override void Define(IPermissionDefinitionContext context) var myGroup = context.AddGroup(MyProjectNamePermissions.GroupName);
{ //Define your own permissions here. Example:
var myGroup = context.AddGroup(MyProjectNamePermissions.GroupName); //myGroup.AddPermission(MyProjectNamePermissions.MyPermission1, L("Permission:MyPermission1"));
//Define your own permissions here. Example: }
//myGroup.AddPermission(MyProjectNamePermissions.MyPermission1, L("Permission:MyPermission1"));
}
private static LocalizableString L(string name) private static LocalizableString L(string name)
{ {
return LocalizableString.Create<MyProjectNameResource>(name); return LocalizableString.Create<MyProjectNameResource>(name);
}
} }
} }

15
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/Permissions/MyProjectNamePermissions.cs

@ -1,10 +1,9 @@
namespace MyCompanyName.MyProjectName.Permissions namespace MyCompanyName.MyProjectName.Permissions;
public static class MyProjectNamePermissions
{ {
public static class MyProjectNamePermissions public const string GroupName = "MyProjectName";
{
public const string GroupName = "MyProjectName";
//Add your own permission names. Example: //Add your own permission names. Example:
//public const string MyPermission1 = GroupName + ".MyPermission1"; //public const string MyPermission1 = GroupName + ".MyPermission1";
} }
}

15
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application/MyProjectNameAppService.cs

@ -4,15 +4,14 @@ using System.Text;
using MyCompanyName.MyProjectName.Localization; using MyCompanyName.MyProjectName.Localization;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
namespace MyCompanyName.MyProjectName namespace MyCompanyName.MyProjectName;
/* Inherit your application services from this class.
*/
public abstract class MyProjectNameAppService : ApplicationService
{ {
/* Inherit your application services from this class. protected MyProjectNameAppService()
*/
public abstract class MyProjectNameAppService : ApplicationService
{ {
protected MyProjectNameAppService() LocalizationResource = typeof(MyProjectNameResource);
{
LocalizationResource = typeof(MyProjectNameResource);
}
} }
} }

15
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application/MyProjectNameApplicationAutoMapperProfile.cs

@ -1,14 +1,13 @@
using AutoMapper; using AutoMapper;
namespace MyCompanyName.MyProjectName namespace MyCompanyName.MyProjectName;
public class MyProjectNameApplicationAutoMapperProfile : Profile
{ {
public class MyProjectNameApplicationAutoMapperProfile : Profile public MyProjectNameApplicationAutoMapperProfile()
{ {
public MyProjectNameApplicationAutoMapperProfile() /* You can configure your AutoMapper mapping configuration here.
{ * Alternatively, you can split your mapping configurations
/* You can configure your AutoMapper mapping configuration here. * into multiple profile classes for a better organization. */
* Alternatively, you can split your mapping configurations
* into multiple profile classes for a better organization. */
}
} }
} }

35
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application/MyProjectNameApplicationModule.cs

@ -7,26 +7,25 @@ using Volo.Abp.PermissionManagement;
using Volo.Abp.SettingManagement; using Volo.Abp.SettingManagement;
using Volo.Abp.TenantManagement; using Volo.Abp.TenantManagement;
namespace MyCompanyName.MyProjectName namespace MyCompanyName.MyProjectName;
[DependsOn(
typeof(MyProjectNameDomainModule),
typeof(AbpAccountApplicationModule),
typeof(MyProjectNameApplicationContractsModule),
typeof(AbpIdentityApplicationModule),
typeof(AbpPermissionManagementApplicationModule),
typeof(AbpTenantManagementApplicationModule),
typeof(AbpFeatureManagementApplicationModule),
typeof(AbpSettingManagementApplicationModule)
)]
public class MyProjectNameApplicationModule : AbpModule
{ {
[DependsOn( public override void ConfigureServices(ServiceConfigurationContext context)
typeof(MyProjectNameDomainModule),
typeof(AbpAccountApplicationModule),
typeof(MyProjectNameApplicationContractsModule),
typeof(AbpIdentityApplicationModule),
typeof(AbpPermissionManagementApplicationModule),
typeof(AbpTenantManagementApplicationModule),
typeof(AbpFeatureManagementApplicationModule),
typeof(AbpSettingManagementApplicationModule)
)]
public class MyProjectNameApplicationModule : AbpModule
{ {
public override void ConfigureServices(ServiceConfigurationContext context) Configure<AbpAutoMapperOptions>(options =>
{ {
Configure<AbpAutoMapperOptions>(options => options.AddMaps<MyProjectNameApplicationModule>();
{ });
options.AddMaps<MyProjectNameApplicationModule>();
});
}
} }
} }

11
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Components/Toolbar/LoginLink/LoginLinkViewComponent.cs

@ -1,13 +1,12 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc;
namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered.Components.Toolbar.LoginLink namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered.Components.Toolbar.LoginLink;
public class LoginLinkViewComponent : AbpViewComponent
{ {
public class LoginLinkViewComponent : AbpViewComponent public virtual IViewComponentResult Invoke()
{ {
public virtual IViewComponentResult Invoke() return View("~/Components/Toolbar/LoginLink/Default.cshtml");
{
return View("~/Components/Toolbar/LoginLink/Default.cshtml");
}
} }
} }

9
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Controllers/AccountController.cs

@ -1,9 +1,8 @@
using Volo.Abp.AspNetCore.Mvc.Authentication; using Volo.Abp.AspNetCore.Mvc.Authentication;
namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered.Controllers namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered.Controllers;
public class AccountController : ChallengeAccountController
{ {
public class AccountController : ChallengeAccountController
{
} }
}

103
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Menus/MyProjectNameMenuContributor.cs

@ -12,71 +12,70 @@ using Volo.Abp.TenantManagement.Blazor.Navigation;
using Volo.Abp.UI.Navigation; using Volo.Abp.UI.Navigation;
using Volo.Abp.Users; using Volo.Abp.Users;
namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered.Menus namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered.Menus;
public class MyProjectNameMenuContributor : IMenuContributor
{ {
public class MyProjectNameMenuContributor : IMenuContributor private readonly IConfiguration _configuration;
public MyProjectNameMenuContributor(IConfiguration configuration)
{ {
private readonly IConfiguration _configuration; _configuration = configuration;
}
public MyProjectNameMenuContributor(IConfiguration configuration) public async Task ConfigureMenuAsync(MenuConfigurationContext context)
{
if (context.Menu.Name == StandardMenus.Main)
{ {
_configuration = configuration; await ConfigureMainMenuAsync(context);
} }
else if (context.Menu.Name == StandardMenus.User)
public async Task ConfigureMenuAsync(MenuConfigurationContext context)
{ {
if (context.Menu.Name == StandardMenus.Main) await ConfigureUserMenuAsync(context);
{
await ConfigureMainMenuAsync(context);
}
else if (context.Menu.Name == StandardMenus.User)
{
await ConfigureUserMenuAsync(context);
}
} }
}
private Task ConfigureMainMenuAsync(MenuConfigurationContext context) private Task ConfigureMainMenuAsync(MenuConfigurationContext context)
{ {
var administration = context.Menu.GetAdministration(); var administration = context.Menu.GetAdministration();
var l = context.GetLocalizer<MyProjectNameResource>(); var l = context.GetLocalizer<MyProjectNameResource>();
context.Menu.Items.Insert( context.Menu.Items.Insert(
0, 0,
new ApplicationMenuItem( new ApplicationMenuItem(
MyProjectNameMenus.Home, MyProjectNameMenus.Home,
l["Menu:Home"], l["Menu:Home"],
"/", "/",
icon: "fas fa-home", icon: "fas fa-home",
order: 0 order: 0
) )
); );
if (MultiTenancyConsts.IsEnabled)
{
administration.SetSubItemOrder(TenantManagementMenuNames.GroupName, 1);
}
else
{
administration.TryRemoveMenuItem(TenantManagementMenuNames.GroupName);
}
administration.SetSubItemOrder(IdentityMenuNames.GroupName, 2);
administration.SetSubItemOrder(SettingManagementMenus.GroupName, 3);
return Task.CompletedTask; if (MultiTenancyConsts.IsEnabled)
{
administration.SetSubItemOrder(TenantManagementMenuNames.GroupName, 1);
} }
else
private Task ConfigureUserMenuAsync(MenuConfigurationContext context)
{ {
var l = context.GetLocalizer<MyProjectNameResource>(); administration.TryRemoveMenuItem(TenantManagementMenuNames.GroupName);
var accountStringLocalizer = context.GetLocalizer<AccountResource>(); }
var identityServerUrl = _configuration["AuthServer:Authority"] ?? "";
context.Menu.AddItem(new ApplicationMenuItem("Account.Manage", accountStringLocalizer["MyAccount"], administration.SetSubItemOrder(IdentityMenuNames.GroupName, 2);
$"{identityServerUrl.EnsureEndsWith('/')}Account/Manage?returnUrl={_configuration["App:SelfUrl"]}", icon: "fa fa-cog", order: 1000, null, "_blank").RequireAuthenticated()); administration.SetSubItemOrder(SettingManagementMenus.GroupName, 3);
context.Menu.AddItem(new ApplicationMenuItem("Account.Logout", l["Logout"], url: "~/Account/Logout", icon: "fa fa-power-off", order: int.MaxValue - 1000).RequireAuthenticated());
return Task.CompletedTask; return Task.CompletedTask;
} }
private Task ConfigureUserMenuAsync(MenuConfigurationContext context)
{
var l = context.GetLocalizer<MyProjectNameResource>();
var accountStringLocalizer = context.GetLocalizer<AccountResource>();
var identityServerUrl = _configuration["AuthServer:Authority"] ?? "";
context.Menu.AddItem(new ApplicationMenuItem("Account.Manage", accountStringLocalizer["MyAccount"],
$"{identityServerUrl.EnsureEndsWith('/')}Account/Manage?returnUrl={_configuration["App:SelfUrl"]}", icon: "fa fa-cog", order: 1000, null, "_blank").RequireAuthenticated());
context.Menu.AddItem(new ApplicationMenuItem("Account.Logout", l["Logout"], url: "~/Account/Logout", icon: "fa fa-power-off", order: int.MaxValue - 1000).RequireAuthenticated());
return Task.CompletedTask;
} }
} }

15
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Menus/MyProjectNameMenus.cs

@ -1,11 +1,10 @@
namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered.Menus namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered.Menus;
public class MyProjectNameMenus
{ {
public class MyProjectNameMenus private const string Prefix = "MyProjectName";
{ public const string Home = Prefix + ".Home";
private const string Prefix = "MyProjectName";
public const string Home = Prefix + ".Home";
//Add your menu items here... //Add your menu items here...
} }
}

25
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Menus/MyProjectNameToolbarContributor.cs

@ -4,23 +4,22 @@ using MyCompanyName.MyProjectName.Blazor.Server.Tiered.Components.Toolbar.LoginL
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Toolbars; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Toolbars;
using Volo.Abp.Users; using Volo.Abp.Users;
namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered.Menus namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered.Menus;
public class MyProjectNameToolbarContributor : IToolbarContributor
{ {
public class MyProjectNameToolbarContributor : IToolbarContributor public virtual Task ConfigureToolbarAsync(IToolbarConfigurationContext context)
{ {
public virtual Task ConfigureToolbarAsync(IToolbarConfigurationContext context) if (context.Toolbar.Name != StandardToolbars.Main)
{ {
if (context.Toolbar.Name != StandardToolbars.Main)
{
return Task.CompletedTask;
}
if (!context.ServiceProvider.GetRequiredService<ICurrentUser>().IsAuthenticated)
{
context.Toolbar.Items.Add(new ToolbarItem(typeof(LoginLinkViewComponent)));
}
return Task.CompletedTask; return Task.CompletedTask;
} }
if (!context.ServiceProvider.GetRequiredService<ICurrentUser>().IsAuthenticated)
{
context.Toolbar.Items.Add(new ToolbarItem(typeof(LoginLinkViewComponent)));
}
return Task.CompletedTask;
} }
} }

443
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/MyProjectNameBlazorModule.cs

@ -48,286 +48,285 @@ using Volo.Abp.UI.Navigation;
using Volo.Abp.UI.Navigation.Urls; using Volo.Abp.UI.Navigation.Urls;
using Volo.Abp.VirtualFileSystem; using Volo.Abp.VirtualFileSystem;
namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered;
[DependsOn(
typeof(MyProjectNameHttpApiClientModule),
typeof(MyProjectNameHttpApiModule),
typeof(AbpCachingStackExchangeRedisModule),
typeof(AbpAspNetCoreMvcClientModule),
typeof(AbpAspNetCoreAuthenticationOpenIdConnectModule),
typeof(AbpHttpClientIdentityModelWebModule),
typeof(AbpAspNetCoreMvcUiBasicThemeModule),
typeof(AbpAutofacModule),
typeof(AbpSwashbuckleModule),
typeof(AbpAspNetCoreSerilogModule),
typeof(AbpAspNetCoreComponentsServerBasicThemeModule),
typeof(AbpIdentityBlazorServerModule),
typeof(AbpTenantManagementBlazorServerModule),
typeof(AbpSettingManagementBlazorServerModule)
)]
public class MyProjectNameBlazorModule : AbpModule
{ {
[DependsOn( public override void PreConfigureServices(ServiceConfigurationContext context)
typeof(MyProjectNameHttpApiClientModule),
typeof(MyProjectNameHttpApiModule),
typeof(AbpCachingStackExchangeRedisModule),
typeof(AbpAspNetCoreMvcClientModule),
typeof(AbpAspNetCoreAuthenticationOpenIdConnectModule),
typeof(AbpHttpClientIdentityModelWebModule),
typeof(AbpAspNetCoreMvcUiBasicThemeModule),
typeof(AbpAutofacModule),
typeof(AbpSwashbuckleModule),
typeof(AbpAspNetCoreSerilogModule),
typeof(AbpAspNetCoreComponentsServerBasicThemeModule),
typeof(AbpIdentityBlazorServerModule),
typeof(AbpTenantManagementBlazorServerModule),
typeof(AbpSettingManagementBlazorServerModule)
)]
public class MyProjectNameBlazorModule : AbpModule
{ {
public override void PreConfigureServices(ServiceConfigurationContext context) context.Services.PreConfigure<AbpMvcDataAnnotationsLocalizationOptions>(options =>
{ {
context.Services.PreConfigure<AbpMvcDataAnnotationsLocalizationOptions>(options => options.AddAssemblyResource(
{ typeof(MyProjectNameResource),
options.AddAssemblyResource( typeof(MyProjectNameDomainSharedModule).Assembly,
typeof(MyProjectNameResource), typeof(MyProjectNameApplicationContractsModule).Assembly,
typeof(MyProjectNameDomainSharedModule).Assembly, typeof(MyProjectNameBlazorModule).Assembly
typeof(MyProjectNameApplicationContractsModule).Assembly, );
typeof(MyProjectNameBlazorModule).Assembly });
); }
});
}
public override void ConfigureServices(ServiceConfigurationContext context) public override void ConfigureServices(ServiceConfigurationContext context)
{ {
var hostingEnvironment = context.Services.GetHostingEnvironment(); var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.GetConfiguration(); var configuration = context.Services.GetConfiguration();
ConfigureUrls(configuration); ConfigureUrls(configuration);
ConfigureCache(); ConfigureCache();
ConfigureBundles(); ConfigureBundles();
ConfigureMultiTenancy(); ConfigureMultiTenancy();
ConfigureAuthentication(context, configuration); ConfigureAuthentication(context, configuration);
ConfigureAutoMapper(); ConfigureAutoMapper();
ConfigureVirtualFileSystem(hostingEnvironment); ConfigureVirtualFileSystem(hostingEnvironment);
ConfigureLocalizationServices(); ConfigureLocalizationServices();
ConfigureBlazorise(context); ConfigureBlazorise(context);
ConfigureRouter(context); ConfigureRouter(context);
ConfigureMenu(configuration); ConfigureMenu(configuration);
ConfigureDataProtection(context, configuration, hostingEnvironment); ConfigureDataProtection(context, configuration, hostingEnvironment);
ConfigureSwaggerServices(context.Services); ConfigureSwaggerServices(context.Services);
} }
private void ConfigureUrls(IConfiguration configuration) private void ConfigureUrls(IConfiguration configuration)
{
Configure<AppUrlOptions>(options =>
{ {
Configure<AppUrlOptions>(options => options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"];
{ });
options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"]; }
});
}
private void ConfigureCache() private void ConfigureCache()
{
Configure<AbpDistributedCacheOptions>(options =>
{ {
Configure<AbpDistributedCacheOptions>(options => options.KeyPrefix = "MyProjectName:";
{ });
options.KeyPrefix = "MyProjectName:"; }
});
}
private void ConfigureBundles() private void ConfigureBundles()
{
Configure<AbpBundlingOptions>(options =>
{ {
Configure<AbpBundlingOptions>(options =>
{
// MVC UI // MVC UI
options.StyleBundles.Configure( options.StyleBundles.Configure(
BasicThemeBundles.Styles.Global, BasicThemeBundles.Styles.Global,
bundle => bundle =>
{ {
bundle.AddFiles("/global-styles.css"); bundle.AddFiles("/global-styles.css");
} }
); );
//BLAZOR UI //BLAZOR UI
options.StyleBundles.Configure( options.StyleBundles.Configure(
BlazorBasicThemeBundles.Styles.Global, BlazorBasicThemeBundles.Styles.Global,
bundle => bundle =>
{ {
bundle.AddFiles("/blazor-global-styles.css"); bundle.AddFiles("/blazor-global-styles.css");
//You can remove the following line if you don't use Blazor CSS isolation for components //You can remove the following line if you don't use Blazor CSS isolation for components
bundle.AddFiles("/MyCompanyName.MyProjectName.Blazor.Server.Tiered.styles.css"); bundle.AddFiles("/MyCompanyName.MyProjectName.Blazor.Server.Tiered.styles.css");
} }
); );
}); });
} }
private void ConfigureMultiTenancy() private void ConfigureMultiTenancy()
{
Configure<AbpMultiTenancyOptions>(options =>
{ {
Configure<AbpMultiTenancyOptions>(options => options.IsEnabled = MultiTenancyConsts.IsEnabled;
{ });
options.IsEnabled = MultiTenancyConsts.IsEnabled; }
});
}
private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration) private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration)
{ {
context.Services.AddAuthentication(options => context.Services.AddAuthentication(options =>
{ {
options.DefaultScheme = "Cookies"; options.DefaultScheme = "Cookies";
options.DefaultChallengeScheme = "oidc"; options.DefaultChallengeScheme = "oidc";
}) })
.AddCookie("Cookies", options => .AddCookie("Cookies", options =>
{ {
options.ExpireTimeSpan = TimeSpan.FromDays(365); options.ExpireTimeSpan = TimeSpan.FromDays(365);
}) })
.AddAbpOpenIdConnect("oidc", options => .AddAbpOpenIdConnect("oidc", options =>
{ {
options.Authority = configuration["AuthServer:Authority"]; options.Authority = configuration["AuthServer:Authority"];
options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]); options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]);
options.ResponseType = OpenIdConnectResponseType.CodeIdToken; options.ResponseType = OpenIdConnectResponseType.CodeIdToken;
options.ClientId = configuration["AuthServer:ClientId"]; options.ClientId = configuration["AuthServer:ClientId"];
options.ClientSecret = configuration["AuthServer:ClientSecret"]; options.ClientSecret = configuration["AuthServer:ClientSecret"];
options.SaveTokens = true; options.SaveTokens = true;
options.GetClaimsFromUserInfoEndpoint = true; options.GetClaimsFromUserInfoEndpoint = true;
options.Scope.Add("role"); options.Scope.Add("role");
options.Scope.Add("email"); options.Scope.Add("email");
options.Scope.Add("phone"); options.Scope.Add("phone");
options.Scope.Add("MyProjectName"); options.Scope.Add("MyProjectName");
}); });
} }
private void ConfigureVirtualFileSystem(IWebHostEnvironment hostingEnvironment) private void ConfigureVirtualFileSystem(IWebHostEnvironment hostingEnvironment)
{
if (hostingEnvironment.IsDevelopment())
{ {
if (hostingEnvironment.IsDevelopment()) Configure<AbpVirtualFileSystemOptions>(options =>
{ {
Configure<AbpVirtualFileSystemOptions>(options =>
{
//<TEMPLATE-REMOVE> //<TEMPLATE-REMOVE>
options.FileSets.ReplaceEmbeddedByPhysical<AbpUiModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.UI", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical<AbpUiModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.UI", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiBootstrapModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Bootstrap", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiBootstrapModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Bootstrap", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiThemeSharedModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiThemeSharedModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiBasicThemeModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}basic-theme{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiBasicThemeModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}basic-theme{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiMultiTenancyModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiMultiTenancyModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy", Path.DirectorySeparatorChar)));
//options.FileSets.ReplaceEmbeddedByPhysical<AbpPermissionManagementWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}permission-management{0}src{0}Volo.Abp.PermissionManagement.Web", Path.DirectorySeparatorChar))); //options.FileSets.ReplaceEmbeddedByPhysical<AbpPermissionManagementWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}permission-management{0}src{0}Volo.Abp.PermissionManagement.Web", Path.DirectorySeparatorChar)));
//options.FileSets.ReplaceEmbeddedByPhysical<AbpFeatureManagementWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}feature-management{0}src{0}Volo.Abp.FeatureManagement.Web", Path.DirectorySeparatorChar))); //options.FileSets.ReplaceEmbeddedByPhysical<AbpFeatureManagementWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}feature-management{0}src{0}Volo.Abp.FeatureManagement.Web", Path.DirectorySeparatorChar)));
//options.FileSets.ReplaceEmbeddedByPhysical<AbpIdentityWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}identity{0}src{0}Volo.Abp.Identity.Web", Path.DirectorySeparatorChar))); //options.FileSets.ReplaceEmbeddedByPhysical<AbpIdentityWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}identity{0}src{0}Volo.Abp.Identity.Web", Path.DirectorySeparatorChar)));
//options.FileSets.ReplaceEmbeddedByPhysical<AbpTenantManagementWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}tenant-management{0}src{0}Volo.Abp.TenantManagement.Web", Path.DirectorySeparatorChar))); //options.FileSets.ReplaceEmbeddedByPhysical<AbpTenantManagementWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}tenant-management{0}src{0}Volo.Abp.TenantManagement.Web", Path.DirectorySeparatorChar)));
//</TEMPLATE-REMOVE> //</TEMPLATE-REMOVE>
options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameDomainSharedModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain.Shared")); options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameDomainSharedModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain.Shared"));
options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameApplicationContractsModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Application.Contracts")); options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameApplicationContractsModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Application.Contracts"));
options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameBlazorModule>(hostingEnvironment.ContentRootPath); options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameBlazorModule>(hostingEnvironment.ContentRootPath);
});
}
}
private void ConfigureLocalizationServices()
{
Configure<AbpLocalizationOptions>(options =>
{
options.Languages.Add(new LanguageInfo("ar", "ar", "العربية"));
options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština"));
options.Languages.Add(new LanguageInfo("en", "en", "English"));
options.Languages.Add(new LanguageInfo("en-GB", "en-GB", "English (UK)"));
options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar"));
options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish"));
options.Languages.Add(new LanguageInfo("fr", "fr", "Français"));
options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in"));
options.Languages.Add(new LanguageInfo("is", "is", "Icelandic", "is"));
options.Languages.Add(new LanguageInfo("it", "it", "Italiano", "it"));
options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português"));
options.Languages.Add(new LanguageInfo("ro-RO", "ro-RO", "Română"));
options.Languages.Add(new LanguageInfo("ru", "ru", "Русский"));
options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak"));
options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe"));
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文"));
options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文"));
options.Languages.Add(new LanguageInfo("de-DE", "de-DE", "Deutsch", "de"));
options.Languages.Add(new LanguageInfo("es", "es", "Español"));
}); });
} }
}
private void ConfigureBlazorise(ServiceConfigurationContext context) private void ConfigureLocalizationServices()
{ {
context.Services Configure<AbpLocalizationOptions>(options =>
.AddBootstrap5Providers()
.AddFontAwesomeIcons();
}
private void ConfigureMenu(IConfiguration configuration)
{ {
Configure<AbpNavigationOptions>(options => options.Languages.Add(new LanguageInfo("ar", "ar", "العربية"));
{ options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština"));
options.MenuContributors.Add(new MyProjectNameMenuContributor(configuration)); options.Languages.Add(new LanguageInfo("en", "en", "English"));
}); options.Languages.Add(new LanguageInfo("en-GB", "en-GB", "English (UK)"));
options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar"));
options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish"));
options.Languages.Add(new LanguageInfo("fr", "fr", "Français"));
options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in"));
options.Languages.Add(new LanguageInfo("is", "is", "Icelandic", "is"));
options.Languages.Add(new LanguageInfo("it", "it", "Italiano", "it"));
options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português"));
options.Languages.Add(new LanguageInfo("ro-RO", "ro-RO", "Română"));
options.Languages.Add(new LanguageInfo("ru", "ru", "Русский"));
options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak"));
options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe"));
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文"));
options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文"));
options.Languages.Add(new LanguageInfo("de-DE", "de-DE", "Deutsch", "de"));
options.Languages.Add(new LanguageInfo("es", "es", "Español"));
});
}
Configure<AbpToolbarOptions>(options => private void ConfigureBlazorise(ServiceConfigurationContext context)
{ {
options.Contributors.Add(new MyProjectNameToolbarContributor()); context.Services
}); .AddBootstrap5Providers()
} .AddFontAwesomeIcons();
}
private void ConfigureRouter(ServiceConfigurationContext context) private void ConfigureMenu(IConfiguration configuration)
{
Configure<AbpNavigationOptions>(options =>
{ {
Configure<AbpRouterOptions>(options => options.MenuContributors.Add(new MyProjectNameMenuContributor(configuration));
{ });
options.AppAssembly = typeof(MyProjectNameBlazorModule).Assembly;
});
}
private void ConfigureAutoMapper() Configure<AbpToolbarOptions>(options =>
{ {
Configure<AbpAutoMapperOptions>(options => options.Contributors.Add(new MyProjectNameToolbarContributor());
{ });
options.AddMaps<MyProjectNameBlazorModule>(); }
});
}
private void ConfigureSwaggerServices(IServiceCollection services) private void ConfigureRouter(ServiceConfigurationContext context)
{
Configure<AbpRouterOptions>(options =>
{ {
services.AddAbpSwaggerGen( options.AppAssembly = typeof(MyProjectNameBlazorModule).Assembly;
options => });
{ }
options.SwaggerDoc("v1", new OpenApiInfo { Title = "MyProjectName API", Version = "v1" });
options.DocInclusionPredicate((docName, description) => true);
options.CustomSchemaIds(type => type.FullName);
}
);
}
private void ConfigureDataProtection( private void ConfigureAutoMapper()
ServiceConfigurationContext context, {
IConfiguration configuration, Configure<AbpAutoMapperOptions>(options =>
IWebHostEnvironment hostingEnvironment)
{ {
var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("MyProjectName"); options.AddMaps<MyProjectNameBlazorModule>();
if (!hostingEnvironment.IsDevelopment()) });
}
private void ConfigureSwaggerServices(IServiceCollection services)
{
services.AddAbpSwaggerGen(
options =>
{ {
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); options.SwaggerDoc("v1", new OpenApiInfo { Title = "MyProjectName API", Version = "v1" });
dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys"); options.DocInclusionPredicate((docName, description) => true);
options.CustomSchemaIds(type => type.FullName);
} }
} );
}
public override void OnApplicationInitialization(ApplicationInitializationContext context) private void ConfigureDataProtection(
ServiceConfigurationContext context,
IConfiguration configuration,
IWebHostEnvironment hostingEnvironment)
{
var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("MyProjectName");
if (!hostingEnvironment.IsDevelopment())
{ {
var env = context.GetEnvironment(); var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]);
var app = context.GetApplicationBuilder(); dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys");
}
}
if (env.IsDevelopment()) public override void OnApplicationInitialization(ApplicationInitializationContext context)
{ {
app.UseDeveloperExceptionPage(); var env = context.GetEnvironment();
} var app = context.GetApplicationBuilder();
app.UseAbpRequestLocalization(); if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
if (!env.IsDevelopment()) app.UseAbpRequestLocalization();
{
app.UseErrorPage();
}
app.UseCorrelationId(); if (!env.IsDevelopment())
app.UseStaticFiles(); {
app.UseRouting(); app.UseErrorPage();
app.UseAuthentication(); }
if (MultiTenancyConsts.IsEnabled) app.UseCorrelationId();
{ app.UseStaticFiles();
app.UseMultiTenancy(); app.UseRouting();
} app.UseAuthentication();
app.UseAuthorization(); if (MultiTenancyConsts.IsEnabled)
app.UseSwagger(); {
app.UseAbpSwaggerUI(options => app.UseMultiTenancy();
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "MyProjectName API");
});
app.UseAbpSerilogEnrichers();
app.UseConfiguredEndpoints();
} }
app.UseAuthorization();
app.UseSwagger();
app.UseAbpSwaggerUI(options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "MyProjectName API");
});
app.UseAbpSerilogEnrichers();
app.UseConfiguredEndpoints();
} }
} }

11
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/MyProjectNameBrandingProvider.cs

@ -1,11 +1,10 @@
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
using Volo.Abp.Ui.Branding; using Volo.Abp.Ui.Branding;
namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered;
[Dependency(ReplaceServices = true)]
public class MyProjectNameBrandingProvider : DefaultBrandingProvider
{ {
[Dependency(ReplaceServices = true)] public override string AppName => "MyProjectName";
public class MyProjectNameBrandingProvider : DefaultBrandingProvider
{
public override string AppName => "MyProjectName";
}
} }

11
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/MyProjectNameComponentBase.cs

@ -1,13 +1,12 @@
using MyCompanyName.MyProjectName.Localization; using MyCompanyName.MyProjectName.Localization;
using Volo.Abp.AspNetCore.Components; using Volo.Abp.AspNetCore.Components;
namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered;
public abstract class MyProjectNameComponentBase : AbpComponentBase
{ {
public abstract class MyProjectNameComponentBase : AbpComponentBase protected MyProjectNameComponentBase()
{ {
protected MyProjectNameComponentBase() LocalizationResource = typeof(MyProjectNameResource);
{
LocalizationResource = typeof(MyProjectNameResource);
}
} }
} }

7
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Pages/Index.razor.cs

@ -1,7 +1,6 @@
namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered.Pages namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered.Pages;
public partial class Index
{ {
public partial class Index
{
}
} }

65
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Program.cs

@ -5,52 +5,51 @@ using Microsoft.Extensions.Hosting;
using Serilog; using Serilog;
using Serilog.Events; using Serilog.Events;
namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered;
public class Program
{ {
public class Program public static int Main(string[] args)
{ {
public static int Main(string[] args) Log.Logger = new LoggerConfiguration()
{
Log.Logger = new LoggerConfiguration()
#if DEBUG #if DEBUG
.MinimumLevel.Debug() .MinimumLevel.Debug()
#else #else
.MinimumLevel.Information() .MinimumLevel.Information()
#endif #endif
.MinimumLevel.Override("Microsoft", LogEventLevel.Information) .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) .MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
.Enrich.FromLogContext() .Enrich.FromLogContext()
.WriteTo.Async(c => c.File("Logs/logs.txt")) .WriteTo.Async(c => c.File("Logs/logs.txt"))
#if DEBUG #if DEBUG
.WriteTo.Async(c => c.Console()) .WriteTo.Async(c => c.Console())
#endif #endif
.CreateLogger(); .CreateLogger();
try try
{ {
Log.Information("Starting web host."); Log.Information("Starting web host.");
CreateHostBuilder(args).Build().Run(); CreateHostBuilder(args).Build().Run();
return 0; return 0;
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Fatal(ex, "Host terminated unexpectedly!"); Log.Fatal(ex, "Host terminated unexpectedly!");
return 1; return 1;
} }
finally finally
{ {
Log.CloseAndFlush(); Log.CloseAndFlush();
}
} }
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.AddAppSettingsSecretsJson()
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.UseAutofac()
.UseSerilog();
} }
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.AddAppSettingsSecretsJson()
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.UseAutofac()
.UseSerilog();
} }

19
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Startup.cs

@ -2,18 +2,17 @@ using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered;
public class Startup
{ {
public class Startup public void ConfigureServices(IServiceCollection services)
{ {
public void ConfigureServices(IServiceCollection services) services.AddApplication<MyProjectNameBlazorModule>();
{ }
services.AddApplication<MyProjectNameBlazorModule>();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{ {
app.InitializeApplication(); app.InitializeApplication();
}
} }
} }

67
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/Menus/MyProjectNameMenuContributor.cs

@ -6,47 +6,46 @@ using Volo.Abp.SettingManagement.Blazor.Menus;
using Volo.Abp.TenantManagement.Blazor.Navigation; using Volo.Abp.TenantManagement.Blazor.Navigation;
using Volo.Abp.UI.Navigation; using Volo.Abp.UI.Navigation;
namespace MyCompanyName.MyProjectName.Blazor.Server.Menus namespace MyCompanyName.MyProjectName.Blazor.Server.Menus;
public class MyProjectNameMenuContributor : IMenuContributor
{ {
public class MyProjectNameMenuContributor : IMenuContributor public async Task ConfigureMenuAsync(MenuConfigurationContext context)
{ {
public async Task ConfigureMenuAsync(MenuConfigurationContext context) if (context.Menu.Name == StandardMenus.Main)
{ {
if (context.Menu.Name == StandardMenus.Main) await ConfigureMainMenuAsync(context);
{
await ConfigureMainMenuAsync(context);
}
} }
}
private Task ConfigureMainMenuAsync(MenuConfigurationContext context) private Task ConfigureMainMenuAsync(MenuConfigurationContext context)
{ {
var administration = context.Menu.GetAdministration(); var administration = context.Menu.GetAdministration();
var l = context.GetLocalizer<MyProjectNameResource>(); var l = context.GetLocalizer<MyProjectNameResource>();
context.Menu.Items.Insert(
0,
new ApplicationMenuItem(
MyProjectNameMenus.Home,
l["Menu:Home"],
"/",
icon: "fas fa-home",
order: 0
)
);
if (MultiTenancyConsts.IsEnabled)
{
administration.SetSubItemOrder(TenantManagementMenuNames.GroupName, 1);
}
else
{
administration.TryRemoveMenuItem(TenantManagementMenuNames.GroupName);
}
administration.SetSubItemOrder(IdentityMenuNames.GroupName, 2); context.Menu.Items.Insert(
administration.SetSubItemOrder(SettingManagementMenus.GroupName, 3); 0,
new ApplicationMenuItem(
MyProjectNameMenus.Home,
l["Menu:Home"],
"/",
icon: "fas fa-home",
order: 0
)
);
return Task.CompletedTask; if (MultiTenancyConsts.IsEnabled)
{
administration.SetSubItemOrder(TenantManagementMenuNames.GroupName, 1);
}
else
{
administration.TryRemoveMenuItem(TenantManagementMenuNames.GroupName);
} }
administration.SetSubItemOrder(IdentityMenuNames.GroupName, 2);
administration.SetSubItemOrder(SettingManagementMenus.GroupName, 3);
return Task.CompletedTask;
} }
} }

15
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/Menus/MyProjectNameMenus.cs

@ -1,11 +1,10 @@
namespace MyCompanyName.MyProjectName.Blazor.Server.Menus namespace MyCompanyName.MyProjectName.Blazor.Server.Menus;
public class MyProjectNameMenus
{ {
public class MyProjectNameMenus private const string Prefix = "MyProjectName";
{ public const string Home = Prefix + ".Home";
private const string Prefix = "MyProjectName";
public const string Home = Prefix + ".Home";
//Add your menu items here... //Add your menu items here...
} }
}

383
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/MyProjectNameBlazorModule.cs

@ -42,116 +42,116 @@ using Volo.Abp.UI.Navigation;
using Volo.Abp.UI.Navigation.Urls; using Volo.Abp.UI.Navigation.Urls;
using Volo.Abp.VirtualFileSystem; using Volo.Abp.VirtualFileSystem;
namespace MyCompanyName.MyProjectName.Blazor.Server namespace MyCompanyName.MyProjectName.Blazor.Server;
[DependsOn(
typeof(MyProjectNameApplicationModule),
typeof(MyProjectNameEntityFrameworkCoreModule),
typeof(MyProjectNameHttpApiModule),
typeof(AbpAspNetCoreMvcUiBasicThemeModule),
typeof(AbpAutofacModule),
typeof(AbpSwashbuckleModule),
typeof(AbpAspNetCoreAuthenticationJwtBearerModule),
typeof(AbpAspNetCoreSerilogModule),
typeof(AbpAccountWebIdentityServerModule),
typeof(AbpAspNetCoreComponentsServerBasicThemeModule),
typeof(AbpIdentityBlazorServerModule),
typeof(AbpTenantManagementBlazorServerModule),
typeof(AbpSettingManagementBlazorServerModule)
)]
public class MyProjectNameBlazorModule : AbpModule
{ {
[DependsOn( public override void PreConfigureServices(ServiceConfigurationContext context)
typeof(MyProjectNameApplicationModule),
typeof(MyProjectNameEntityFrameworkCoreModule),
typeof(MyProjectNameHttpApiModule),
typeof(AbpAspNetCoreMvcUiBasicThemeModule),
typeof(AbpAutofacModule),
typeof(AbpSwashbuckleModule),
typeof(AbpAspNetCoreAuthenticationJwtBearerModule),
typeof(AbpAspNetCoreSerilogModule),
typeof(AbpAccountWebIdentityServerModule),
typeof(AbpAspNetCoreComponentsServerBasicThemeModule),
typeof(AbpIdentityBlazorServerModule),
typeof(AbpTenantManagementBlazorServerModule),
typeof(AbpSettingManagementBlazorServerModule)
)]
public class MyProjectNameBlazorModule : AbpModule
{ {
public override void PreConfigureServices(ServiceConfigurationContext context) context.Services.PreConfigure<AbpMvcDataAnnotationsLocalizationOptions>(options =>
{ {
context.Services.PreConfigure<AbpMvcDataAnnotationsLocalizationOptions>(options => options.AddAssemblyResource(
{ typeof(MyProjectNameResource),
options.AddAssemblyResource( typeof(MyProjectNameDomainModule).Assembly,
typeof(MyProjectNameResource), typeof(MyProjectNameDomainSharedModule).Assembly,
typeof(MyProjectNameDomainModule).Assembly, typeof(MyProjectNameApplicationModule).Assembly,
typeof(MyProjectNameDomainSharedModule).Assembly, typeof(MyProjectNameApplicationContractsModule).Assembly,
typeof(MyProjectNameApplicationModule).Assembly, typeof(MyProjectNameBlazorModule).Assembly
typeof(MyProjectNameApplicationContractsModule).Assembly, );
typeof(MyProjectNameBlazorModule).Assembly });
); }
});
}
public override void ConfigureServices(ServiceConfigurationContext context) public override void ConfigureServices(ServiceConfigurationContext context)
{ {
var hostingEnvironment = context.Services.GetHostingEnvironment(); var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.GetConfiguration(); var configuration = context.Services.GetConfiguration();
ConfigureUrls(configuration); ConfigureUrls(configuration);
ConfigureBundles(); ConfigureBundles();
ConfigureAuthentication(context, configuration); ConfigureAuthentication(context, configuration);
ConfigureAutoMapper(); ConfigureAutoMapper();
ConfigureVirtualFileSystem(hostingEnvironment); ConfigureVirtualFileSystem(hostingEnvironment);
ConfigureLocalizationServices(); ConfigureLocalizationServices();
ConfigureSwaggerServices(context.Services); ConfigureSwaggerServices(context.Services);
ConfigureAutoApiControllers(); ConfigureAutoApiControllers();
ConfigureBlazorise(context); ConfigureBlazorise(context);
ConfigureRouter(context); ConfigureRouter(context);
ConfigureMenu(context); ConfigureMenu(context);
} }
private void ConfigureUrls(IConfiguration configuration) private void ConfigureUrls(IConfiguration configuration)
{
Configure<AppUrlOptions>(options =>
{ {
Configure<AppUrlOptions>(options => options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"];
{ });
options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"]; }
});
}
private void ConfigureBundles() private void ConfigureBundles()
{
Configure<AbpBundlingOptions>(options =>
{ {
Configure<AbpBundlingOptions>(options =>
{
// MVC UI // MVC UI
options.StyleBundles.Configure( options.StyleBundles.Configure(
BasicThemeBundles.Styles.Global, BasicThemeBundles.Styles.Global,
bundle => bundle =>
{ {
bundle.AddFiles("/global-styles.css"); bundle.AddFiles("/global-styles.css");
} }
); );
//BLAZOR UI //BLAZOR UI
options.StyleBundles.Configure( options.StyleBundles.Configure(
BlazorBasicThemeBundles.Styles.Global, BlazorBasicThemeBundles.Styles.Global,
bundle => bundle =>
{ {
bundle.AddFiles("/blazor-global-styles.css"); bundle.AddFiles("/blazor-global-styles.css");
//You can remove the following line if you don't use Blazor CSS isolation for components //You can remove the following line if you don't use Blazor CSS isolation for components
bundle.AddFiles("/MyCompanyName.MyProjectName.Blazor.Server.styles.css"); bundle.AddFiles("/MyCompanyName.MyProjectName.Blazor.Server.styles.css");
} }
); );
}); });
} }
private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration) private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration)
{ {
context.Services.AddAuthentication() context.Services.AddAuthentication()
.AddJwtBearer(options => .AddJwtBearer(options =>
{ {
options.Authority = configuration["AuthServer:Authority"]; options.Authority = configuration["AuthServer:Authority"];
options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]); options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]);
options.Audience = "MyProjectName"; options.Audience = "MyProjectName";
}); });
} }
private void ConfigureVirtualFileSystem(IWebHostEnvironment hostingEnvironment) private void ConfigureVirtualFileSystem(IWebHostEnvironment hostingEnvironment)
{
if (hostingEnvironment.IsDevelopment())
{ {
if (hostingEnvironment.IsDevelopment()) Configure<AbpVirtualFileSystemOptions>(options =>
{ {
Configure<AbpVirtualFileSystemOptions>(options =>
{
//<TEMPLATE-REMOVE> //<TEMPLATE-REMOVE>
options.FileSets.ReplaceEmbeddedByPhysical<AbpUiModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.UI", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical<AbpUiModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.UI", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiBootstrapModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Bootstrap", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiBootstrapModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Bootstrap", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiThemeSharedModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiThemeSharedModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiBasicThemeModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}basic-theme{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiBasicThemeModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}basic-theme{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiMultiTenancyModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiMultiTenancyModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy", Path.DirectorySeparatorChar)));
//options.FileSets.ReplaceEmbeddedByPhysical<AbpPermissionManagementWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}permission-management{0}src{0}Volo.Abp.PermissionManagement.Web", Path.DirectorySeparatorChar))); //options.FileSets.ReplaceEmbeddedByPhysical<AbpPermissionManagementWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}permission-management{0}src{0}Volo.Abp.PermissionManagement.Web", Path.DirectorySeparatorChar)));
//options.FileSets.ReplaceEmbeddedByPhysical<AbpFeatureManagementWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}feature-management{0}src{0}Volo.Abp.FeatureManagement.Web", Path.DirectorySeparatorChar))); //options.FileSets.ReplaceEmbeddedByPhysical<AbpFeatureManagementWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}feature-management{0}src{0}Volo.Abp.FeatureManagement.Web", Path.DirectorySeparatorChar)));
//options.FileSets.ReplaceEmbeddedByPhysical<AbpIdentityWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}identity{0}src{0}Volo.Abp.Identity.Web", Path.DirectorySeparatorChar))); //options.FileSets.ReplaceEmbeddedByPhysical<AbpIdentityWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}identity{0}src{0}Volo.Abp.Identity.Web", Path.DirectorySeparatorChar)));
@ -159,129 +159,128 @@ namespace MyCompanyName.MyProjectName.Blazor.Server
//options.FileSets.ReplaceEmbeddedByPhysical<AbpTenantManagementWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}tenant-management{0}src{0}Volo.Abp.TenantManagement.Web", Path.DirectorySeparatorChar))); //options.FileSets.ReplaceEmbeddedByPhysical<AbpTenantManagementWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}tenant-management{0}src{0}Volo.Abp.TenantManagement.Web", Path.DirectorySeparatorChar)));
//</TEMPLATE-REMOVE> //</TEMPLATE-REMOVE>
options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameDomainSharedModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain.Shared")); options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameDomainSharedModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain.Shared"));
options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameDomainModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain")); options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameDomainModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain"));
options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameApplicationContractsModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Application.Contracts")); options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameApplicationContractsModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Application.Contracts"));
options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameApplicationModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Application")); options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameApplicationModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Application"));
options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameBlazorModule>(hostingEnvironment.ContentRootPath); options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameBlazorModule>(hostingEnvironment.ContentRootPath);
});
}
}
private void ConfigureLocalizationServices()
{
Configure<AbpLocalizationOptions>(options =>
{
options.Languages.Add(new LanguageInfo("ar", "ar", "العربية"));
options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština"));
options.Languages.Add(new LanguageInfo("en", "en", "English"));
options.Languages.Add(new LanguageInfo("en-GB", "en-GB", "English (UK)"));
options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar"));
options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish"));
options.Languages.Add(new LanguageInfo("fr", "fr", "Français"));
options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in"));
options.Languages.Add(new LanguageInfo("is", "is", "Icelandic", "is"));
options.Languages.Add(new LanguageInfo("it", "it", "Italiano", "it"));
options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português"));
options.Languages.Add(new LanguageInfo("ro-RO", "ro-RO", "Română"));
options.Languages.Add(new LanguageInfo("ru", "ru", "Русский"));
options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak"));
options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe"));
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文"));
options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文"));
options.Languages.Add(new LanguageInfo("de-DE", "de-DE", "Deutsch", "de"));
options.Languages.Add(new LanguageInfo("es", "es", "Español"));
}); });
} }
}
private void ConfigureSwaggerServices(IServiceCollection services) private void ConfigureLocalizationServices()
{ {
services.AddAbpSwaggerGen( Configure<AbpLocalizationOptions>(options =>
options =>
{
options.SwaggerDoc("v1", new OpenApiInfo { Title = "MyProjectName API", Version = "v1" });
options.DocInclusionPredicate((docName, description) => true);
options.CustomSchemaIds(type => type.FullName);
}
);
}
private void ConfigureBlazorise(ServiceConfigurationContext context)
{ {
context.Services options.Languages.Add(new LanguageInfo("ar", "ar", "العربية"));
.AddBootstrap5Providers() options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština"));
.AddFontAwesomeIcons(); options.Languages.Add(new LanguageInfo("en", "en", "English"));
} options.Languages.Add(new LanguageInfo("en-GB", "en-GB", "English (UK)"));
options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar"));
options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish"));
options.Languages.Add(new LanguageInfo("fr", "fr", "Français"));
options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in"));
options.Languages.Add(new LanguageInfo("is", "is", "Icelandic", "is"));
options.Languages.Add(new LanguageInfo("it", "it", "Italiano", "it"));
options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português"));
options.Languages.Add(new LanguageInfo("ro-RO", "ro-RO", "Română"));
options.Languages.Add(new LanguageInfo("ru", "ru", "Русский"));
options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak"));
options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe"));
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文"));
options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文"));
options.Languages.Add(new LanguageInfo("de-DE", "de-DE", "Deutsch", "de"));
options.Languages.Add(new LanguageInfo("es", "es", "Español"));
});
}
private void ConfigureMenu(ServiceConfigurationContext context) private void ConfigureSwaggerServices(IServiceCollection services)
{ {
Configure<AbpNavigationOptions>(options => services.AddAbpSwaggerGen(
options =>
{ {
options.MenuContributors.Add(new MyProjectNameMenuContributor()); options.SwaggerDoc("v1", new OpenApiInfo { Title = "MyProjectName API", Version = "v1" });
}); options.DocInclusionPredicate((docName, description) => true);
} options.CustomSchemaIds(type => type.FullName);
}
);
}
private void ConfigureRouter(ServiceConfigurationContext context) private void ConfigureBlazorise(ServiceConfigurationContext context)
{
context.Services
.AddBootstrap5Providers()
.AddFontAwesomeIcons();
}
private void ConfigureMenu(ServiceConfigurationContext context)
{
Configure<AbpNavigationOptions>(options =>
{ {
Configure<AbpRouterOptions>(options => options.MenuContributors.Add(new MyProjectNameMenuContributor());
{ });
options.AppAssembly = typeof(MyProjectNameBlazorModule).Assembly; }
});
}
private void ConfigureAutoApiControllers() private void ConfigureRouter(ServiceConfigurationContext context)
{
Configure<AbpRouterOptions>(options =>
{ {
Configure<AbpAspNetCoreMvcOptions>(options => options.AppAssembly = typeof(MyProjectNameBlazorModule).Assembly;
{ });
options.ConventionalControllers.Create(typeof(MyProjectNameApplicationModule).Assembly); }
});
}
private void ConfigureAutoMapper() private void ConfigureAutoApiControllers()
{
Configure<AbpAspNetCoreMvcOptions>(options =>
{ {
Configure<AbpAutoMapperOptions>(options => options.ConventionalControllers.Create(typeof(MyProjectNameApplicationModule).Assembly);
{ });
options.AddMaps<MyProjectNameBlazorModule>(); }
});
}
public override void OnApplicationInitialization(ApplicationInitializationContext context) private void ConfigureAutoMapper()
{
Configure<AbpAutoMapperOptions>(options =>
{ {
var env = context.GetEnvironment(); options.AddMaps<MyProjectNameBlazorModule>();
var app = context.GetApplicationBuilder(); });
}
app.UseAbpRequestLocalization(); public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var env = context.GetEnvironment();
var app = context.GetApplicationBuilder();
if (env.IsDevelopment()) app.UseAbpRequestLocalization();
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Error");
app.UseHsts();
}
app.UseHttpsRedirection(); if (env.IsDevelopment())
app.UseCorrelationId(); {
app.UseStaticFiles(); app.UseDeveloperExceptionPage();
app.UseRouting(); }
app.UseAuthentication(); else
app.UseJwtTokenMiddleware(); {
app.UseExceptionHandler("/Error");
app.UseHsts();
}
if (MultiTenancyConsts.IsEnabled) app.UseHttpsRedirection();
{ app.UseCorrelationId();
app.UseMultiTenancy(); app.UseStaticFiles();
} app.UseRouting();
app.UseAuthentication();
app.UseJwtTokenMiddleware();
app.UseUnitOfWork(); if (MultiTenancyConsts.IsEnabled)
app.UseIdentityServer(); {
app.UseAuthorization(); app.UseMultiTenancy();
app.UseSwagger();
app.UseAbpSwaggerUI(options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "MyProjectName API");
});
app.UseConfiguredEndpoints();
} }
app.UseUnitOfWork();
app.UseIdentityServer();
app.UseAuthorization();
app.UseSwagger();
app.UseAbpSwaggerUI(options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "MyProjectName API");
});
app.UseConfiguredEndpoints();
} }
} }

11
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/MyProjectNameBrandingProvider.cs

@ -1,11 +1,10 @@
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
using Volo.Abp.Ui.Branding; using Volo.Abp.Ui.Branding;
namespace MyCompanyName.MyProjectName.Blazor.Server namespace MyCompanyName.MyProjectName.Blazor.Server;
[Dependency(ReplaceServices = true)]
public class MyProjectNameBrandingProvider : DefaultBrandingProvider
{ {
[Dependency(ReplaceServices = true)] public override string AppName => "MyProjectName";
public class MyProjectNameBrandingProvider : DefaultBrandingProvider
{
public override string AppName => "MyProjectName";
}
} }

11
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/MyProjectNameComponentBase.cs

@ -1,13 +1,12 @@
using MyCompanyName.MyProjectName.Localization; using MyCompanyName.MyProjectName.Localization;
using Volo.Abp.AspNetCore.Components; using Volo.Abp.AspNetCore.Components;
namespace MyCompanyName.MyProjectName.Blazor.Server namespace MyCompanyName.MyProjectName.Blazor.Server;
public abstract class MyProjectNameComponentBase : AbpComponentBase
{ {
public abstract class MyProjectNameComponentBase : AbpComponentBase protected MyProjectNameComponentBase()
{ {
protected MyProjectNameComponentBase() LocalizationResource = typeof(MyProjectNameResource);
{
LocalizationResource = typeof(MyProjectNameResource);
}
} }
} }

7
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/Pages/Index.razor.cs

@ -1,7 +1,6 @@
namespace MyCompanyName.MyProjectName.Blazor.Server.Pages namespace MyCompanyName.MyProjectName.Blazor.Server.Pages;
public partial class Index
{ {
public partial class Index
{
}
} }

65
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/Program.cs

@ -5,52 +5,51 @@ using Microsoft.Extensions.Hosting;
using Serilog; using Serilog;
using Serilog.Events; using Serilog.Events;
namespace MyCompanyName.MyProjectName.Blazor.Server namespace MyCompanyName.MyProjectName.Blazor.Server;
public class Program
{ {
public class Program public static int Main(string[] args)
{ {
public static int Main(string[] args) Log.Logger = new LoggerConfiguration()
{
Log.Logger = new LoggerConfiguration()
#if DEBUG #if DEBUG
.MinimumLevel.Debug() .MinimumLevel.Debug()
#else #else
.MinimumLevel.Information() .MinimumLevel.Information()
#endif #endif
.MinimumLevel.Override("Microsoft", LogEventLevel.Information) .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) .MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
.Enrich.FromLogContext() .Enrich.FromLogContext()
.WriteTo.Async(c => c.File("Logs/logs.txt")) .WriteTo.Async(c => c.File("Logs/logs.txt"))
#if DEBUG #if DEBUG
.WriteTo.Async(c => c.Console()) .WriteTo.Async(c => c.Console())
#endif #endif
.CreateLogger(); .CreateLogger();
try try
{ {
Log.Information("Starting web host."); Log.Information("Starting web host.");
CreateHostBuilder(args).Build().Run(); CreateHostBuilder(args).Build().Run();
return 0; return 0;
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Fatal(ex, "Host terminated unexpectedly!"); Log.Fatal(ex, "Host terminated unexpectedly!");
return 1; return 1;
} }
finally finally
{ {
Log.CloseAndFlush(); Log.CloseAndFlush();
}
} }
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.AddAppSettingsSecretsJson()
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.UseAutofac()
.UseSerilog();
} }
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.AddAppSettingsSecretsJson()
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.UseAutofac()
.UseSerilog();
} }

19
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/Startup.cs

@ -2,18 +2,17 @@ using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
namespace MyCompanyName.MyProjectName.Blazor.Server namespace MyCompanyName.MyProjectName.Blazor.Server;
public class Startup
{ {
public class Startup public void ConfigureServices(IServiceCollection services)
{ {
public void ConfigureServices(IServiceCollection services) services.AddApplication<MyProjectNameBlazorModule>();
{ }
services.AddApplication<MyProjectNameBlazorModule>();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{ {
app.InitializeApplication(); app.InitializeApplication();
}
} }
} }

83
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Menus/MyProjectNameMenuContributor.cs

@ -8,61 +8,60 @@ using Volo.Abp.Authorization.Permissions;
using Volo.Abp.UI.Navigation; using Volo.Abp.UI.Navigation;
using Volo.Abp.Users; using Volo.Abp.Users;
namespace MyCompanyName.MyProjectName.Blazor.Menus namespace MyCompanyName.MyProjectName.Blazor.Menus;
public class MyProjectNameMenuContributor : IMenuContributor
{ {
public class MyProjectNameMenuContributor : IMenuContributor private readonly IConfiguration _configuration;
public MyProjectNameMenuContributor(IConfiguration configuration)
{ {
private readonly IConfiguration _configuration; _configuration = configuration;
}
public MyProjectNameMenuContributor(IConfiguration configuration) public async Task ConfigureMenuAsync(MenuConfigurationContext context)
{
if (context.Menu.Name == StandardMenus.Main)
{ {
_configuration = configuration; await ConfigureMainMenuAsync(context);
} }
else if (context.Menu.Name == StandardMenus.User)
public async Task ConfigureMenuAsync(MenuConfigurationContext context)
{ {
if (context.Menu.Name == StandardMenus.Main) await ConfigureUserMenuAsync(context);
{
await ConfigureMainMenuAsync(context);
}
else if (context.Menu.Name == StandardMenus.User)
{
await ConfigureUserMenuAsync(context);
}
} }
}
private Task ConfigureMainMenuAsync(MenuConfigurationContext context) private Task ConfigureMainMenuAsync(MenuConfigurationContext context)
{ {
var l = context.GetLocalizer<MyProjectNameResource>(); var l = context.GetLocalizer<MyProjectNameResource>();
context.Menu.Items.Insert( context.Menu.Items.Insert(
0, 0,
new ApplicationMenuItem( new ApplicationMenuItem(
MyProjectNameMenus.Home, MyProjectNameMenus.Home,
l["Menu:Home"], l["Menu:Home"],
"/", "/",
icon: "fas fa-home" icon: "fas fa-home"
) )
); );
return Task.CompletedTask; return Task.CompletedTask;
} }
private Task ConfigureUserMenuAsync(MenuConfigurationContext context) private Task ConfigureUserMenuAsync(MenuConfigurationContext context)
{ {
var accountStringLocalizer = context.GetLocalizer<AccountResource>(); var accountStringLocalizer = context.GetLocalizer<AccountResource>();
var identityServerUrl = _configuration["AuthServer:Authority"] ?? ""; var identityServerUrl = _configuration["AuthServer:Authority"] ?? "";
context.Menu.AddItem(new ApplicationMenuItem( context.Menu.AddItem(new ApplicationMenuItem(
"Account.Manage", "Account.Manage",
accountStringLocalizer["MyAccount"], accountStringLocalizer["MyAccount"],
$"{identityServerUrl.EnsureEndsWith('/')}Account/Manage?returnUrl={_configuration["App:SelfUrl"]}", $"{identityServerUrl.EnsureEndsWith('/')}Account/Manage?returnUrl={_configuration["App:SelfUrl"]}",
icon: "fa fa-cog", icon: "fa fa-cog",
order: 1000, order: 1000,
null).RequireAuthenticated()); null).RequireAuthenticated());
return Task.CompletedTask; return Task.CompletedTask;
}
} }
} }

15
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Menus/MyProjectNameMenus.cs

@ -1,11 +1,10 @@
namespace MyCompanyName.MyProjectName.Blazor.Menus namespace MyCompanyName.MyProjectName.Blazor.Menus;
public class MyProjectNameMenus
{ {
public class MyProjectNameMenus private const string Prefix = "MyProjectName";
{ public const string Home = Prefix + ".Home";
private const string Prefix = "MyProjectName";
public const string Home = Prefix + ".Home";
//Add your menu items here... //Add your menu items here...
} }
}

11
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBlazorAutoMapperProfile.cs

@ -1,12 +1,11 @@
using AutoMapper; using AutoMapper;
namespace MyCompanyName.MyProjectName.Blazor namespace MyCompanyName.MyProjectName.Blazor;
public class MyProjectNameBlazorAutoMapperProfile : Profile
{ {
public class MyProjectNameBlazorAutoMapperProfile : Profile public MyProjectNameBlazorAutoMapperProfile()
{ {
public MyProjectNameBlazorAutoMapperProfile() //Define your AutoMapper configuration here for the Blazor project.
{
//Define your AutoMapper configuration here for the Blazor project.
}
} }
} }

133
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBlazorModule.cs

@ -18,87 +18,86 @@ using Volo.Abp.Identity.Blazor.WebAssembly;
using Volo.Abp.SettingManagement.Blazor.WebAssembly; using Volo.Abp.SettingManagement.Blazor.WebAssembly;
using Volo.Abp.TenantManagement.Blazor.WebAssembly; using Volo.Abp.TenantManagement.Blazor.WebAssembly;
namespace MyCompanyName.MyProjectName.Blazor namespace MyCompanyName.MyProjectName.Blazor;
[DependsOn(
typeof(AbpAutofacWebAssemblyModule),
typeof(MyProjectNameHttpApiClientModule),
typeof(AbpAspNetCoreComponentsWebAssemblyBasicThemeModule),
typeof(AbpIdentityBlazorWebAssemblyModule),
typeof(AbpTenantManagementBlazorWebAssemblyModule),
typeof(AbpSettingManagementBlazorWebAssemblyModule)
)]
public class MyProjectNameBlazorModule : AbpModule
{ {
[DependsOn( public override void ConfigureServices(ServiceConfigurationContext context)
typeof(AbpAutofacWebAssemblyModule),
typeof(MyProjectNameHttpApiClientModule),
typeof(AbpAspNetCoreComponentsWebAssemblyBasicThemeModule),
typeof(AbpIdentityBlazorWebAssemblyModule),
typeof(AbpTenantManagementBlazorWebAssemblyModule),
typeof(AbpSettingManagementBlazorWebAssemblyModule)
)]
public class MyProjectNameBlazorModule : AbpModule
{ {
public override void ConfigureServices(ServiceConfigurationContext context) var environment = context.Services.GetSingletonInstance<IWebAssemblyHostEnvironment>();
{ var builder = context.Services.GetSingletonInstance<WebAssemblyHostBuilder>();
var environment = context.Services.GetSingletonInstance<IWebAssemblyHostEnvironment>();
var builder = context.Services.GetSingletonInstance<WebAssemblyHostBuilder>();
ConfigureAuthentication(builder); ConfigureAuthentication(builder);
ConfigureHttpClient(context, environment); ConfigureHttpClient(context, environment);
ConfigureBlazorise(context); ConfigureBlazorise(context);
ConfigureRouter(context); ConfigureRouter(context);
ConfigureUI(builder); ConfigureUI(builder);
ConfigureMenu(context); ConfigureMenu(context);
ConfigureAutoMapper(context); ConfigureAutoMapper(context);
} }
private void ConfigureRouter(ServiceConfigurationContext context) private void ConfigureRouter(ServiceConfigurationContext context)
{
Configure<AbpRouterOptions>(options =>
{ {
Configure<AbpRouterOptions>(options => options.AppAssembly = typeof(MyProjectNameBlazorModule).Assembly;
{ });
options.AppAssembly = typeof(MyProjectNameBlazorModule).Assembly; }
});
}
private void ConfigureMenu(ServiceConfigurationContext context) private void ConfigureMenu(ServiceConfigurationContext context)
{
Configure<AbpNavigationOptions>(options =>
{ {
Configure<AbpNavigationOptions>(options => options.MenuContributors.Add(new MyProjectNameMenuContributor(context.Services.GetConfiguration()));
{ });
options.MenuContributors.Add(new MyProjectNameMenuContributor(context.Services.GetConfiguration())); }
});
}
private void ConfigureBlazorise(ServiceConfigurationContext context) private void ConfigureBlazorise(ServiceConfigurationContext context)
{ {
context.Services context.Services
.AddBootstrap5Providers() .AddBootstrap5Providers()
.AddFontAwesomeIcons(); .AddFontAwesomeIcons();
} }
private static void ConfigureAuthentication(WebAssemblyHostBuilder builder) private static void ConfigureAuthentication(WebAssemblyHostBuilder builder)
{
builder.Services.AddOidcAuthentication(options =>
{ {
builder.Services.AddOidcAuthentication(options => builder.Configuration.Bind("AuthServer", options.ProviderOptions);
{ options.UserOptions.RoleClaim = JwtClaimTypes.Role;
builder.Configuration.Bind("AuthServer", options.ProviderOptions); options.ProviderOptions.DefaultScopes.Add("MyProjectName");
options.UserOptions.RoleClaim = JwtClaimTypes.Role; options.ProviderOptions.DefaultScopes.Add("role");
options.ProviderOptions.DefaultScopes.Add("MyProjectName"); options.ProviderOptions.DefaultScopes.Add("email");
options.ProviderOptions.DefaultScopes.Add("role"); options.ProviderOptions.DefaultScopes.Add("phone");
options.ProviderOptions.DefaultScopes.Add("email"); });
options.ProviderOptions.DefaultScopes.Add("phone"); }
});
}
private static void ConfigureUI(WebAssemblyHostBuilder builder) private static void ConfigureUI(WebAssemblyHostBuilder builder)
{ {
builder.RootComponents.Add<App>("#ApplicationContainer"); builder.RootComponents.Add<App>("#ApplicationContainer");
} }
private static void ConfigureHttpClient(ServiceConfigurationContext context, IWebAssemblyHostEnvironment environment) private static void ConfigureHttpClient(ServiceConfigurationContext context, IWebAssemblyHostEnvironment environment)
{
context.Services.AddTransient(sp => new HttpClient
{ {
context.Services.AddTransient(sp => new HttpClient BaseAddress = new Uri(environment.BaseAddress)
{ });
BaseAddress = new Uri(environment.BaseAddress) }
});
}
private void ConfigureAutoMapper(ServiceConfigurationContext context) private void ConfigureAutoMapper(ServiceConfigurationContext context)
{
Configure<AbpAutoMapperOptions>(options =>
{ {
Configure<AbpAutoMapperOptions>(options => options.AddMaps<MyProjectNameBlazorModule>();
{ });
options.AddMaps<MyProjectNameBlazorModule>();
});
}
} }
} }

11
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBrandingProvider.cs

@ -1,11 +1,10 @@
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
using Volo.Abp.Ui.Branding; using Volo.Abp.Ui.Branding;
namespace MyCompanyName.MyProjectName.Blazor namespace MyCompanyName.MyProjectName.Blazor;
[Dependency(ReplaceServices = true)]
public class MyProjectNameBrandingProvider : DefaultBrandingProvider
{ {
[Dependency(ReplaceServices = true)] public override string AppName => "MyProjectName";
public class MyProjectNameBrandingProvider : DefaultBrandingProvider
{
public override string AppName => "MyProjectName";
}
} }

25
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBundleContributor.cs

@ -1,20 +1,19 @@
using Volo.Abp.Bundling; using Volo.Abp.Bundling;
namespace MyCompanyName.MyProjectName.Blazor namespace MyCompanyName.MyProjectName.Blazor;
/* Add your global styles/scripts here.
* See https://docs.abp.io/en/abp/latest/UI/Blazor/Global-Scripts-Styles to learn how to use it
*/
public class MyProjectNameBundleContributor : IBundleContributor
{ {
/* Add your global styles/scripts here. public void AddScripts(BundleContext context)
* See https://docs.abp.io/en/abp/latest/UI/Blazor/Global-Scripts-Styles to learn how to use it
*/
public class MyProjectNameBundleContributor : IBundleContributor
{ {
public void AddScripts(BundleContext context)
{
} }
public void AddStyles(BundleContext context) public void AddStyles(BundleContext context)
{ {
context.Add("main.css", true); context.Add("main.css", true);
}
} }
} }

11
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameComponentBase.cs

@ -1,13 +1,12 @@
using MyCompanyName.MyProjectName.Localization; using MyCompanyName.MyProjectName.Localization;
using Volo.Abp.AspNetCore.Components; using Volo.Abp.AspNetCore.Components;
namespace MyCompanyName.MyProjectName.Blazor namespace MyCompanyName.MyProjectName.Blazor;
public abstract class MyProjectNameComponentBase : AbpComponentBase
{ {
public abstract class MyProjectNameComponentBase : AbpComponentBase protected MyProjectNameComponentBase()
{ {
protected MyProjectNameComponentBase() LocalizationResource = typeof(MyProjectNameResource);
{
LocalizationResource = typeof(MyProjectNameResource);
}
} }
} }

7
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Pages/Index.razor.cs

@ -1,7 +1,6 @@
namespace MyCompanyName.MyProjectName.Blazor.Pages namespace MyCompanyName.MyProjectName.Blazor.Pages;
public partial class Index
{ {
public partial class Index
{
}
} }

25
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Program.cs

@ -1,24 +1,23 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting; using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
namespace MyCompanyName.MyProjectName.Blazor namespace MyCompanyName.MyProjectName.Blazor;
public class Program
{ {
public class Program public static async Task Main(string[] args)
{ {
public static async Task Main(string[] args) var builder = WebAssemblyHostBuilder.CreateDefault(args);
{
var builder = WebAssemblyHostBuilder.CreateDefault(args);
var application = builder.AddApplication<MyProjectNameBlazorModule>(options => var application = builder.AddApplication<MyProjectNameBlazorModule>(options =>
{ {
options.UseAutofac(); options.UseAutofac();
}); });
var host = builder.Build(); var host = builder.Build();
await application.InitializeAsync(host.Services); await application.InitializeAsync(host.Services);
await host.RunAsync(); await host.RunAsync();
}
} }
} }

59
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/DbMigratorHostedService.cs

@ -7,41 +7,40 @@ using MyCompanyName.MyProjectName.Data;
using Serilog; using Serilog;
using Volo.Abp; using Volo.Abp;
namespace MyCompanyName.MyProjectName.DbMigrator namespace MyCompanyName.MyProjectName.DbMigrator;
public class DbMigratorHostedService : IHostedService
{ {
public class DbMigratorHostedService : IHostedService private readonly IHostApplicationLifetime _hostApplicationLifetime;
private readonly IConfiguration _configuration;
public DbMigratorHostedService(IHostApplicationLifetime hostApplicationLifetime, IConfiguration configuration)
{ {
private readonly IHostApplicationLifetime _hostApplicationLifetime; _hostApplicationLifetime = hostApplicationLifetime;
private readonly IConfiguration _configuration; _configuration = configuration;
}
public DbMigratorHostedService(IHostApplicationLifetime hostApplicationLifetime, IConfiguration configuration) public async Task StartAsync(CancellationToken cancellationToken)
{
using (var application = AbpApplicationFactory.Create<MyProjectNameDbMigratorModule>(options =>
{ {
_hostApplicationLifetime = hostApplicationLifetime; options.Services.ReplaceConfiguration(_configuration);
_configuration = configuration; options.UseAutofac();
} options.Services.AddLogging(c => c.AddSerilog());
}))
public async Task StartAsync(CancellationToken cancellationToken)
{ {
using (var application = AbpApplicationFactory.Create<MyProjectNameDbMigratorModule>(options => application.Initialize();
{
options.Services.ReplaceConfiguration(_configuration); await application
options.UseAutofac(); .ServiceProvider
options.Services.AddLogging(c => c.AddSerilog()); .GetRequiredService<MyProjectNameDbMigrationService>()
})) .MigrateAsync();
{
application.Initialize(); application.Shutdown();
await application
.ServiceProvider
.GetRequiredService<MyProjectNameDbMigrationService>()
.MigrateAsync();
application.Shutdown();
_hostApplicationLifetime.StopApplication();
}
}
public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask; _hostApplicationLifetime.StopApplication();
}
} }
public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;
} }

21
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/MyProjectNameDbMigratorModule.cs

@ -3,18 +3,17 @@ using Volo.Abp.Autofac;
using Volo.Abp.BackgroundJobs; using Volo.Abp.BackgroundJobs;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
namespace MyCompanyName.MyProjectName.DbMigrator namespace MyCompanyName.MyProjectName.DbMigrator;
[DependsOn(
typeof(AbpAutofacModule),
typeof(MyProjectNameEntityFrameworkCoreModule),
typeof(MyProjectNameApplicationContractsModule)
)]
public class MyProjectNameDbMigratorModule : AbpModule
{ {
[DependsOn( public override void ConfigureServices(ServiceConfigurationContext context)
typeof(AbpAutofacModule),
typeof(MyProjectNameEntityFrameworkCoreModule),
typeof(MyProjectNameApplicationContractsModule)
)]
public class MyProjectNameDbMigratorModule : AbpModule
{ {
public override void ConfigureServices(ServiceConfigurationContext context) Configure<AbpBackgroundJobOptions>(options => options.IsJobExecutionEnabled = false);
{
Configure<AbpBackgroundJobOptions>(options => options.IsJobExecutionEnabled = false);
}
} }
} }

43
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/Program.cs

@ -7,36 +7,35 @@ using Microsoft.Extensions.Logging;
using Serilog; using Serilog;
using Serilog.Events; using Serilog.Events;
namespace MyCompanyName.MyProjectName.DbMigrator namespace MyCompanyName.MyProjectName.DbMigrator;
class Program
{ {
class Program static async Task Main(string[] args)
{ {
static async Task Main(string[] args) Log.Logger = new LoggerConfiguration()
{ .MinimumLevel.Information()
Log.Logger = new LoggerConfiguration() .MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
.MinimumLevel.Information() .MinimumLevel.Override("Volo.Abp", LogEventLevel.Warning)
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
.MinimumLevel.Override("Volo.Abp", LogEventLevel.Warning)
#if DEBUG #if DEBUG
.MinimumLevel.Override("MyCompanyName.MyProjectName", LogEventLevel.Debug) .MinimumLevel.Override("MyCompanyName.MyProjectName", LogEventLevel.Debug)
#else #else
.MinimumLevel.Override("MyCompanyName.MyProjectName", LogEventLevel.Information) .MinimumLevel.Override("MyCompanyName.MyProjectName", LogEventLevel.Information)
#endif #endif
.Enrich.FromLogContext() .Enrich.FromLogContext()
.WriteTo.Async(c => c.File("Logs/logs.txt")) .WriteTo.Async(c => c.File("Logs/logs.txt"))
.WriteTo.Async(c => c.Console()) .WriteTo.Async(c => c.Console())
.CreateLogger(); .CreateLogger();
await CreateHostBuilder(args).RunConsoleAsync();
}
public static IHostBuilder CreateHostBuilder(string[] args) => await CreateHostBuilder(args).RunConsoleAsync();
Host.CreateDefaultBuilder(args)
.AddAppSettingsSecretsJson()
.ConfigureLogging((context, logging) => logging.ClearProviders())
.ConfigureServices((hostContext, services) =>
{
services.AddHostedService<DbMigratorHostedService>();
});
} }
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.AddAppSettingsSecretsJson()
.ConfigureLogging((context, logging) => logging.ClearProviders())
.ConfigureServices((hostContext, services) =>
{
services.AddHostedService<DbMigratorHostedService>();
});
} }

11
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/Localization/MyProjectNameResource.cs

@ -1,10 +1,9 @@
using Volo.Abp.Localization; using Volo.Abp.Localization;
namespace MyCompanyName.MyProjectName.Localization namespace MyCompanyName.MyProjectName.Localization;
[LocalizationResourceName("MyProjectName")]
public class MyProjectNameResource
{ {
[LocalizationResourceName("MyProjectName")]
public class MyProjectNameResource
{
} }
}

17
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MultiTenancy/MultiTenancyConsts.cs

@ -1,11 +1,10 @@
namespace MyCompanyName.MyProjectName.MultiTenancy namespace MyCompanyName.MyProjectName.MultiTenancy;
public static class MultiTenancyConsts
{ {
public static class MultiTenancyConsts /* Enable/disable multi-tenancy easily in a single point.
{ * If you will never need to multi-tenancy, you can remove
/* Enable/disable multi-tenancy easily in a single point. * related modules and code parts, including this file.
* If you will never need to multi-tenancy, you can remove */
* related modules and code parts, including this file. public const bool IsEnabled = true;
*/
public const bool IsEnabled = true;
}
} }

9
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MyProjectNameDomainErrorCodes.cs

@ -1,7 +1,6 @@
namespace MyCompanyName.MyProjectName namespace MyCompanyName.MyProjectName;
public static class MyProjectNameDomainErrorCodes
{ {
public static class MyProjectNameDomainErrorCodes /* You can add your business exception error codes here, as constants */
{
/* You can add your business exception error codes here, as constants */
}
} }

69
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MyProjectNameDomainSharedModule.cs

@ -13,47 +13,46 @@ using Volo.Abp.TenantManagement;
using Volo.Abp.Validation.Localization; using Volo.Abp.Validation.Localization;
using Volo.Abp.VirtualFileSystem; using Volo.Abp.VirtualFileSystem;
namespace MyCompanyName.MyProjectName namespace MyCompanyName.MyProjectName;
[DependsOn(
typeof(AbpAuditLoggingDomainSharedModule),
typeof(AbpBackgroundJobsDomainSharedModule),
typeof(AbpFeatureManagementDomainSharedModule),
typeof(AbpIdentityDomainSharedModule),
typeof(AbpIdentityServerDomainSharedModule),
typeof(AbpPermissionManagementDomainSharedModule),
typeof(AbpSettingManagementDomainSharedModule),
typeof(AbpTenantManagementDomainSharedModule)
)]
public class MyProjectNameDomainSharedModule : AbpModule
{ {
[DependsOn( public override void PreConfigureServices(ServiceConfigurationContext context)
typeof(AbpAuditLoggingDomainSharedModule),
typeof(AbpBackgroundJobsDomainSharedModule),
typeof(AbpFeatureManagementDomainSharedModule),
typeof(AbpIdentityDomainSharedModule),
typeof(AbpIdentityServerDomainSharedModule),
typeof(AbpPermissionManagementDomainSharedModule),
typeof(AbpSettingManagementDomainSharedModule),
typeof(AbpTenantManagementDomainSharedModule)
)]
public class MyProjectNameDomainSharedModule : AbpModule
{ {
public override void PreConfigureServices(ServiceConfigurationContext context) MyProjectNameGlobalFeatureConfigurator.Configure();
{ MyProjectNameModuleExtensionConfigurator.Configure();
MyProjectNameGlobalFeatureConfigurator.Configure(); }
MyProjectNameModuleExtensionConfigurator.Configure();
}
public override void ConfigureServices(ServiceConfigurationContext context) public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpVirtualFileSystemOptions>(options =>
{ {
Configure<AbpVirtualFileSystemOptions>(options => options.FileSets.AddEmbedded<MyProjectNameDomainSharedModule>();
{ });
options.FileSets.AddEmbedded<MyProjectNameDomainSharedModule>();
});
Configure<AbpLocalizationOptions>(options => Configure<AbpLocalizationOptions>(options =>
{ {
options.Resources options.Resources
.Add<MyProjectNameResource>("en") .Add<MyProjectNameResource>("en")
.AddBaseTypes(typeof(AbpValidationResource)) .AddBaseTypes(typeof(AbpValidationResource))
.AddVirtualJson("/Localization/MyProjectName"); .AddVirtualJson("/Localization/MyProjectName");
options.DefaultResourceType = typeof(MyProjectNameResource); options.DefaultResourceType = typeof(MyProjectNameResource);
}); });
Configure<AbpExceptionLocalizationOptions>(options => Configure<AbpExceptionLocalizationOptions>(options =>
{ {
options.MapCodeNamespace("MyProjectName", typeof(MyProjectNameResource)); options.MapCodeNamespace("MyProjectName", typeof(MyProjectNameResource));
}); });
}
} }
} }

17
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MyProjectNameGlobalFeatureConfigurator.cs

@ -1,15 +1,15 @@
using Volo.Abp.Threading; using Volo.Abp.Threading;
namespace MyCompanyName.MyProjectName namespace MyCompanyName.MyProjectName;
public static class MyProjectNameGlobalFeatureConfigurator
{ {
public static class MyProjectNameGlobalFeatureConfigurator private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner();
{
private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner();
public static void Configure() public static void Configure()
{
OneTimeRunner.Run(() =>
{ {
OneTimeRunner.Run(() =>
{
/* You can configure (enable/disable) global features of the used modules here. /* You can configure (enable/disable) global features of the used modules here.
* *
* YOU CAN SAFELY DELETE THIS CLASS AND REMOVE ITS USAGES IF YOU DON'T NEED TO IT! * YOU CAN SAFELY DELETE THIS CLASS AND REMOVE ITS USAGES IF YOU DON'T NEED TO IT!
@ -17,7 +17,6 @@ namespace MyCompanyName.MyProjectName
* Please refer to the documentation to lear more about the Global Features System: * Please refer to the documentation to lear more about the Global Features System:
* https://docs.abp.io/en/abp/latest/Global-Features * https://docs.abp.io/en/abp/latest/Global-Features
*/ */
}); });
}
} }
} }

105
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MyProjectNameModuleExtensionConfigurator.cs

@ -3,70 +3,69 @@ using Volo.Abp.Identity;
using Volo.Abp.ObjectExtending; using Volo.Abp.ObjectExtending;
using Volo.Abp.Threading; using Volo.Abp.Threading;
namespace MyCompanyName.MyProjectName namespace MyCompanyName.MyProjectName;
public static class MyProjectNameModuleExtensionConfigurator
{ {
public static class MyProjectNameModuleExtensionConfigurator private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner();
{
private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner();
public static void Configure() public static void Configure()
{
OneTimeRunner.Run(() =>
{ {
OneTimeRunner.Run(() => ConfigureExistingProperties();
{ ConfigureExtraProperties();
ConfigureExistingProperties(); });
ConfigureExtraProperties(); }
});
}
private static void ConfigureExistingProperties() private static void ConfigureExistingProperties()
{ {
/* You can change max lengths for properties of the /* You can change max lengths for properties of the
* entities defined in the modules used by your application. * entities defined in the modules used by your application.
* *
* Example: Change user and role name max lengths * Example: Change user and role name max lengths
IdentityUserConsts.MaxNameLength = 99; IdentityUserConsts.MaxNameLength = 99;
IdentityRoleConsts.MaxNameLength = 99; IdentityRoleConsts.MaxNameLength = 99;
* Notice: It is not suggested to change property lengths * Notice: It is not suggested to change property lengths
* unless you really need it. Go with the standard values wherever possible. * unless you really need it. Go with the standard values wherever possible.
* *
* If you are using EF Core, you will need to run the add-migration command after your changes. * If you are using EF Core, you will need to run the add-migration command after your changes.
*/ */
} }
private static void ConfigureExtraProperties() private static void ConfigureExtraProperties()
{ {
/* You can configure extra properties for the /* You can configure extra properties for the
* entities defined in the modules used by your application. * entities defined in the modules used by your application.
* *
* This class can be used to define these extra properties * This class can be used to define these extra properties
* with a high level, easy to use API. * with a high level, easy to use API.
* *
* Example: Add a new property to the user entity of the identity module * Example: Add a new property to the user entity of the identity module
ObjectExtensionManager.Instance.Modules() ObjectExtensionManager.Instance.Modules()
.ConfigureIdentity(identity => .ConfigureIdentity(identity =>
{
identity.ConfigureUser(user =>
{ {
identity.ConfigureUser(user => user.AddOrUpdateProperty<string>( //property type: string
{ "SocialSecurityNumber", //property name
user.AddOrUpdateProperty<string>( //property type: string property =>
"SocialSecurityNumber", //property name {
property => //validation rules
{ property.Attributes.Add(new RequiredAttribute());
//validation rules property.Attributes.Add(new StringLengthAttribute(64) {MinimumLength = 4});
property.Attributes.Add(new RequiredAttribute());
property.Attributes.Add(new StringLengthAttribute(64) {MinimumLength = 4});
//...other configurations for this property //...other configurations for this property
} }
); );
});
}); });
});
* See the documentation for more: * See the documentation for more:
* https://docs.abp.io/en/abp/latest/Module-Entity-Extensions * https://docs.abp.io/en/abp/latest/Module-Entity-Extensions
*/ */
}
} }
} }

9
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Data/IMyProjectNameDbSchemaMigrator.cs

@ -1,9 +1,8 @@
using System.Threading.Tasks; using System.Threading.Tasks;
namespace MyCompanyName.MyProjectName.Data namespace MyCompanyName.MyProjectName.Data;
public interface IMyProjectNameDbSchemaMigrator
{ {
public interface IMyProjectNameDbSchemaMigrator Task MigrateAsync();
{
Task MigrateAsync();
}
} }

297
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Data/MyProjectNameDbMigrationService.cs

@ -13,212 +13,211 @@ using Volo.Abp.Identity;
using Volo.Abp.MultiTenancy; using Volo.Abp.MultiTenancy;
using Volo.Abp.TenantManagement; using Volo.Abp.TenantManagement;
namespace MyCompanyName.MyProjectName.Data namespace MyCompanyName.MyProjectName.Data;
public class MyProjectNameDbMigrationService : ITransientDependency
{ {
public class MyProjectNameDbMigrationService : ITransientDependency public ILogger<MyProjectNameDbMigrationService> Logger { get; set; }
private readonly IDataSeeder _dataSeeder;
private readonly IEnumerable<IMyProjectNameDbSchemaMigrator> _dbSchemaMigrators;
private readonly ITenantRepository _tenantRepository;
private readonly ICurrentTenant _currentTenant;
public MyProjectNameDbMigrationService(
IDataSeeder dataSeeder,
IEnumerable<IMyProjectNameDbSchemaMigrator> dbSchemaMigrators,
ITenantRepository tenantRepository,
ICurrentTenant currentTenant)
{ {
public ILogger<MyProjectNameDbMigrationService> Logger { get; set; } _dataSeeder = dataSeeder;
_dbSchemaMigrators = dbSchemaMigrators;
private readonly IDataSeeder _dataSeeder; _tenantRepository = tenantRepository;
private readonly IEnumerable<IMyProjectNameDbSchemaMigrator> _dbSchemaMigrators; _currentTenant = currentTenant;
private readonly ITenantRepository _tenantRepository;
private readonly ICurrentTenant _currentTenant;
public MyProjectNameDbMigrationService(
IDataSeeder dataSeeder,
IEnumerable<IMyProjectNameDbSchemaMigrator> dbSchemaMigrators,
ITenantRepository tenantRepository,
ICurrentTenant currentTenant)
{
_dataSeeder = dataSeeder;
_dbSchemaMigrators = dbSchemaMigrators;
_tenantRepository = tenantRepository;
_currentTenant = currentTenant;
Logger = NullLogger<MyProjectNameDbMigrationService>.Instance; Logger = NullLogger<MyProjectNameDbMigrationService>.Instance;
} }
public async Task MigrateAsync() public async Task MigrateAsync()
{ {
//<TEMPLATE-REMOVE IF-NOT='EFCORE'> //<TEMPLATE-REMOVE IF-NOT='EFCORE'>
var initialMigrationAdded = AddInitialMigrationIfNotExist(); var initialMigrationAdded = AddInitialMigrationIfNotExist();
if (initialMigrationAdded) if (initialMigrationAdded)
{ {
return; return;
} }
//</TEMPLATE-REMOVE> //</TEMPLATE-REMOVE>
Logger.LogInformation("Started database migrations..."); Logger.LogInformation("Started database migrations...");
await MigrateDatabaseSchemaAsync(); await MigrateDatabaseSchemaAsync();
await SeedDataAsync(); await SeedDataAsync();
Logger.LogInformation($"Successfully completed host database migrations."); Logger.LogInformation($"Successfully completed host database migrations.");
var tenants = await _tenantRepository.GetListAsync(includeDetails: true); var tenants = await _tenantRepository.GetListAsync(includeDetails: true);
var migratedDatabaseSchemas = new HashSet<string>(); var migratedDatabaseSchemas = new HashSet<string>();
foreach (var tenant in tenants) foreach (var tenant in tenants)
{
using (_currentTenant.Change(tenant.Id))
{ {
using (_currentTenant.Change(tenant.Id)) if (tenant.ConnectionStrings.Any())
{ {
if (tenant.ConnectionStrings.Any()) var tenantConnectionStrings = tenant.ConnectionStrings
{ .Select(x => x.Value)
var tenantConnectionStrings = tenant.ConnectionStrings .ToList();
.Select(x => x.Value)
.ToList();
if (!migratedDatabaseSchemas.IsSupersetOf(tenantConnectionStrings)) if (!migratedDatabaseSchemas.IsSupersetOf(tenantConnectionStrings))
{ {
await MigrateDatabaseSchemaAsync(tenant); await MigrateDatabaseSchemaAsync(tenant);
migratedDatabaseSchemas.AddIfNotContains(tenantConnectionStrings); migratedDatabaseSchemas.AddIfNotContains(tenantConnectionStrings);
}
} }
await SeedDataAsync(tenant);
} }
Logger.LogInformation($"Successfully completed {tenant.Name} tenant database migrations."); await SeedDataAsync(tenant);
} }
Logger.LogInformation("Successfully completed all database migrations."); Logger.LogInformation($"Successfully completed {tenant.Name} tenant database migrations.");
Logger.LogInformation("You can safely end this process...");
} }
private async Task MigrateDatabaseSchemaAsync(Tenant tenant = null) Logger.LogInformation("Successfully completed all database migrations.");
{ Logger.LogInformation("You can safely end this process...");
Logger.LogInformation( }
$"Migrating schema for {(tenant == null ? "host" : tenant.Name + " tenant")} database...");
foreach (var migrator in _dbSchemaMigrators) private async Task MigrateDatabaseSchemaAsync(Tenant tenant = null)
{ {
await migrator.MigrateAsync(); Logger.LogInformation(
} $"Migrating schema for {(tenant == null ? "host" : tenant.Name + " tenant")} database...");
}
private async Task SeedDataAsync(Tenant tenant = null) foreach (var migrator in _dbSchemaMigrators)
{ {
Logger.LogInformation($"Executing {(tenant == null ? "host" : tenant.Name + " tenant")} database seed..."); await migrator.MigrateAsync();
await _dataSeeder.SeedAsync(new DataSeedContext(tenant?.Id)
.WithProperty(IdentityDataSeedContributor.AdminEmailPropertyName, IdentityDataSeedContributor.AdminEmailDefaultValue)
.WithProperty(IdentityDataSeedContributor.AdminPasswordPropertyName, IdentityDataSeedContributor.AdminPasswordDefaultValue)
);
} }
}
//<TEMPLATE-REMOVE IF-NOT='EFCORE'> private async Task SeedDataAsync(Tenant tenant = null)
private bool AddInitialMigrationIfNotExist() {
Logger.LogInformation($"Executing {(tenant == null ? "host" : tenant.Name + " tenant")} database seed...");
await _dataSeeder.SeedAsync(new DataSeedContext(tenant?.Id)
.WithProperty(IdentityDataSeedContributor.AdminEmailPropertyName, IdentityDataSeedContributor.AdminEmailDefaultValue)
.WithProperty(IdentityDataSeedContributor.AdminPasswordPropertyName, IdentityDataSeedContributor.AdminPasswordDefaultValue)
);
}
//<TEMPLATE-REMOVE IF-NOT='EFCORE'>
private bool AddInitialMigrationIfNotExist()
{
try
{ {
try if (!DbMigrationsProjectExists())
{
if (!DbMigrationsProjectExists())
{
return false;
}
}
catch (Exception)
{ {
return false; return false;
} }
}
catch (Exception)
{
return false;
}
try try
{
if (!MigrationsFolderExists())
{ {
if (!MigrationsFolderExists()) AddInitialMigration();
{ return true;
AddInitialMigration();
return true;
}
else
{
return false;
}
} }
catch (Exception e) else
{ {
Logger.LogWarning("Couldn't determinate if any migrations exist : " + e.Message);
return false; return false;
} }
} }
catch (Exception e)
private bool DbMigrationsProjectExists()
{ {
var dbMigrationsProjectFolder = GetEntityFrameworkCoreProjectFolderPath(); Logger.LogWarning("Couldn't determinate if any migrations exist : " + e.Message);
return false;
return dbMigrationsProjectFolder != null;
} }
}
private bool MigrationsFolderExists() private bool DbMigrationsProjectExists()
{ {
var dbMigrationsProjectFolder = GetEntityFrameworkCoreProjectFolderPath(); var dbMigrationsProjectFolder = GetEntityFrameworkCoreProjectFolderPath();
return Directory.Exists(Path.Combine(dbMigrationsProjectFolder, "Migrations")); return dbMigrationsProjectFolder != null;
} }
private void AddInitialMigration() private bool MigrationsFolderExists()
{ {
Logger.LogInformation("Creating initial migration..."); var dbMigrationsProjectFolder = GetEntityFrameworkCoreProjectFolderPath();
string argumentPrefix; return Directory.Exists(Path.Combine(dbMigrationsProjectFolder, "Migrations"));
string fileName; }
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) private void AddInitialMigration()
{ {
argumentPrefix = "-c"; Logger.LogInformation("Creating initial migration...");
fileName = "/bin/bash";
}
else
{
argumentPrefix = "/C";
fileName = "cmd.exe";
}
var procStartInfo = new ProcessStartInfo(fileName, string argumentPrefix;
$"{argumentPrefix} \"abp create-migration-and-run-migrator \"{GetEntityFrameworkCoreProjectFolderPath()}\"\"" string fileName;
);
try if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{ {
Process.Start(procStartInfo); argumentPrefix = "-c";
} fileName = "/bin/bash";
catch (Exception)
{
throw new Exception("Couldn't run ABP CLI...");
}
} }
else
private string GetEntityFrameworkCoreProjectFolderPath()
{ {
var slnDirectoryPath = GetSolutionDirectoryPath(); argumentPrefix = "/C";
fileName = "cmd.exe";
}
if (slnDirectoryPath == null) var procStartInfo = new ProcessStartInfo(fileName,
{ $"{argumentPrefix} \"abp create-migration-and-run-migrator \"{GetEntityFrameworkCoreProjectFolderPath()}\"\""
throw new Exception("Solution folder not found!"); );
}
var srcDirectoryPath = Path.Combine(slnDirectoryPath, "src"); try
{
Process.Start(procStartInfo);
}
catch (Exception)
{
throw new Exception("Couldn't run ABP CLI...");
}
}
private string GetEntityFrameworkCoreProjectFolderPath()
{
var slnDirectoryPath = GetSolutionDirectoryPath();
return Directory.GetDirectories(srcDirectoryPath) if (slnDirectoryPath == null)
.FirstOrDefault(d => d.EndsWith(".EntityFrameworkCore")); {
throw new Exception("Solution folder not found!");
} }
private string GetSolutionDirectoryPath() var srcDirectoryPath = Path.Combine(slnDirectoryPath, "src");
return Directory.GetDirectories(srcDirectoryPath)
.FirstOrDefault(d => d.EndsWith(".EntityFrameworkCore"));
}
private string GetSolutionDirectoryPath()
{
var currentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory());
while (Directory.GetParent(currentDirectory.FullName) != null)
{ {
var currentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory()); currentDirectory = Directory.GetParent(currentDirectory.FullName);
while (Directory.GetParent(currentDirectory.FullName) != null) if (Directory.GetFiles(currentDirectory.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null)
{ {
currentDirectory = Directory.GetParent(currentDirectory.FullName); return currentDirectory.FullName;
if (Directory.GetFiles(currentDirectory.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null)
{
return currentDirectory.FullName;
}
} }
return null;
} }
//</TEMPLATE-REMOVE>
return null;
} }
//</TEMPLATE-REMOVE>
} }

19
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Data/NullMyProjectNameDbSchemaMigrator.cs

@ -1,16 +1,15 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
namespace MyCompanyName.MyProjectName.Data namespace MyCompanyName.MyProjectName.Data;
/* This is used if database provider does't define
* IMyProjectNameDbSchemaMigrator implementation.
*/
public class NullMyProjectNameDbSchemaMigrator : IMyProjectNameDbSchemaMigrator, ITransientDependency
{ {
/* This is used if database provider does't define public Task MigrateAsync()
* IMyProjectNameDbSchemaMigrator implementation.
*/
public class NullMyProjectNameDbSchemaMigrator : IMyProjectNameDbSchemaMigrator, ITransientDependency
{ {
public Task MigrateAsync() return Task.CompletedTask;
{
return Task.CompletedTask;
}
} }
} }

527
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/IdentityServer/IdentityServerDataSeedContributor.cs

@ -18,60 +18,60 @@ using ApiResource = Volo.Abp.IdentityServer.ApiResources.ApiResource;
using ApiScope = Volo.Abp.IdentityServer.ApiScopes.ApiScope; using ApiScope = Volo.Abp.IdentityServer.ApiScopes.ApiScope;
using Client = Volo.Abp.IdentityServer.Clients.Client; using Client = Volo.Abp.IdentityServer.Clients.Client;
namespace MyCompanyName.MyProjectName.IdentityServer namespace MyCompanyName.MyProjectName.IdentityServer;
public class IdentityServerDataSeedContributor : IDataSeedContributor, ITransientDependency
{ {
public class IdentityServerDataSeedContributor : IDataSeedContributor, ITransientDependency private readonly IApiResourceRepository _apiResourceRepository;
private readonly IApiScopeRepository _apiScopeRepository;
private readonly IClientRepository _clientRepository;
private readonly IIdentityResourceDataSeeder _identityResourceDataSeeder;
private readonly IGuidGenerator _guidGenerator;
private readonly IPermissionDataSeeder _permissionDataSeeder;
private readonly IConfiguration _configuration;
private readonly ICurrentTenant _currentTenant;
public IdentityServerDataSeedContributor(
IClientRepository clientRepository,
IApiResourceRepository apiResourceRepository,
IApiScopeRepository apiScopeRepository,
IIdentityResourceDataSeeder identityResourceDataSeeder,
IGuidGenerator guidGenerator,
IPermissionDataSeeder permissionDataSeeder,
IConfiguration configuration,
ICurrentTenant currentTenant)
{ {
private readonly IApiResourceRepository _apiResourceRepository; _clientRepository = clientRepository;
private readonly IApiScopeRepository _apiScopeRepository; _apiResourceRepository = apiResourceRepository;
private readonly IClientRepository _clientRepository; _apiScopeRepository = apiScopeRepository;
private readonly IIdentityResourceDataSeeder _identityResourceDataSeeder; _identityResourceDataSeeder = identityResourceDataSeeder;
private readonly IGuidGenerator _guidGenerator; _guidGenerator = guidGenerator;
private readonly IPermissionDataSeeder _permissionDataSeeder; _permissionDataSeeder = permissionDataSeeder;
private readonly IConfiguration _configuration; _configuration = configuration;
private readonly ICurrentTenant _currentTenant; _currentTenant = currentTenant;
}
public IdentityServerDataSeedContributor(
IClientRepository clientRepository,
IApiResourceRepository apiResourceRepository,
IApiScopeRepository apiScopeRepository,
IIdentityResourceDataSeeder identityResourceDataSeeder,
IGuidGenerator guidGenerator,
IPermissionDataSeeder permissionDataSeeder,
IConfiguration configuration,
ICurrentTenant currentTenant)
{
_clientRepository = clientRepository;
_apiResourceRepository = apiResourceRepository;
_apiScopeRepository = apiScopeRepository;
_identityResourceDataSeeder = identityResourceDataSeeder;
_guidGenerator = guidGenerator;
_permissionDataSeeder = permissionDataSeeder;
_configuration = configuration;
_currentTenant = currentTenant;
}
[UnitOfWork] [UnitOfWork]
public virtual async Task SeedAsync(DataSeedContext context) public virtual async Task SeedAsync(DataSeedContext context)
{
using (_currentTenant.Change(context?.TenantId))
{ {
using (_currentTenant.Change(context?.TenantId)) await _identityResourceDataSeeder.CreateStandardResourcesAsync();
{ await CreateApiResourcesAsync();
await _identityResourceDataSeeder.CreateStandardResourcesAsync(); await CreateApiScopesAsync();
await CreateApiResourcesAsync(); await CreateClientsAsync();
await CreateApiScopesAsync();
await CreateClientsAsync();
}
} }
}
private async Task CreateApiScopesAsync() private async Task CreateApiScopesAsync()
{ {
await CreateApiScopeAsync("MyProjectName"); await CreateApiScopeAsync("MyProjectName");
} }
private async Task CreateApiResourcesAsync() private async Task CreateApiResourcesAsync()
{
var commonApiUserClaims = new[]
{ {
var commonApiUserClaims = new[]
{
"email", "email",
"email_verified", "email_verified",
"name", "name",
@ -80,57 +80,57 @@ namespace MyCompanyName.MyProjectName.IdentityServer
"role" "role"
}; };
await CreateApiResourceAsync("MyProjectName", commonApiUserClaims); await CreateApiResourceAsync("MyProjectName", commonApiUserClaims);
} }
private async Task<ApiResource> CreateApiResourceAsync(string name, IEnumerable<string> claims) private async Task<ApiResource> CreateApiResourceAsync(string name, IEnumerable<string> claims)
{
var apiResource = await _apiResourceRepository.FindByNameAsync(name);
if (apiResource == null)
{ {
var apiResource = await _apiResourceRepository.FindByNameAsync(name); apiResource = await _apiResourceRepository.InsertAsync(
if (apiResource == null) new ApiResource(
{ _guidGenerator.Create(),
apiResource = await _apiResourceRepository.InsertAsync( name,
new ApiResource( name + " API"
_guidGenerator.Create(), ),
name, autoSave: true
name + " API" );
),
autoSave: true
);
}
foreach (var claim in claims)
{
if (apiResource.FindClaim(claim) == null)
{
apiResource.AddUserClaim(claim);
}
}
return await _apiResourceRepository.UpdateAsync(apiResource);
} }
private async Task<ApiScope> CreateApiScopeAsync(string name) foreach (var claim in claims)
{ {
var apiScope = await _apiScopeRepository.FindByNameAsync(name); if (apiResource.FindClaim(claim) == null)
if (apiScope == null)
{ {
apiScope = await _apiScopeRepository.InsertAsync( apiResource.AddUserClaim(claim);
new ApiScope(
_guidGenerator.Create(),
name,
name + " API"
),
autoSave: true
);
} }
}
return apiScope; return await _apiResourceRepository.UpdateAsync(apiResource);
}
private async Task<ApiScope> CreateApiScopeAsync(string name)
{
var apiScope = await _apiScopeRepository.FindByNameAsync(name);
if (apiScope == null)
{
apiScope = await _apiScopeRepository.InsertAsync(
new ApiScope(
_guidGenerator.Create(),
name,
name + " API"
),
autoSave: true
);
} }
private async Task CreateClientsAsync() return apiScope;
}
private async Task CreateClientsAsync()
{
var commonScopes = new[]
{ {
var commonScopes = new[]
{
"email", "email",
"openid", "openid",
"profile", "profile",
@ -140,215 +140,214 @@ namespace MyCompanyName.MyProjectName.IdentityServer
"MyProjectName" "MyProjectName"
}; };
var configurationSection = _configuration.GetSection("IdentityServer:Clients"); var configurationSection = _configuration.GetSection("IdentityServer:Clients");
//<TEMPLATE-REMOVE IF-NOT='ui:mvc&&tiered'> //<TEMPLATE-REMOVE IF-NOT='ui:mvc&&tiered'>
//Web Client //Web Client
var webClientId = configurationSection["MyProjectName_Web:ClientId"]; var webClientId = configurationSection["MyProjectName_Web:ClientId"];
if (!webClientId.IsNullOrWhiteSpace()) if (!webClientId.IsNullOrWhiteSpace())
{ {
var webClientRootUrl = configurationSection["MyProjectName_Web:RootUrl"].EnsureEndsWith('/'); var webClientRootUrl = configurationSection["MyProjectName_Web:RootUrl"].EnsureEndsWith('/');
await CreateClientAsync( await CreateClientAsync(
name: webClientId, name: webClientId,
scopes: commonScopes, scopes: commonScopes,
grantTypes: new[] { "hybrid" }, grantTypes: new[] { "hybrid" },
secret: (configurationSection["MyProjectName_Web:ClientSecret"] ?? "1q2w3e*").Sha256(), secret: (configurationSection["MyProjectName_Web:ClientSecret"] ?? "1q2w3e*").Sha256(),
redirectUri: $"{webClientRootUrl}signin-oidc", redirectUri: $"{webClientRootUrl}signin-oidc",
postLogoutRedirectUri: $"{webClientRootUrl}signout-callback-oidc", postLogoutRedirectUri: $"{webClientRootUrl}signout-callback-oidc",
frontChannelLogoutUri: $"{webClientRootUrl}Account/FrontChannelLogout", frontChannelLogoutUri: $"{webClientRootUrl}Account/FrontChannelLogout",
corsOrigins: new[] { webClientRootUrl.RemovePostFix("/") } corsOrigins: new[] { webClientRootUrl.RemovePostFix("/") }
); );
} }
//</TEMPLATE-REMOVE>
//Console Test / Angular Client //</TEMPLATE-REMOVE>
var consoleAndAngularClientId = configurationSection["MyProjectName_App:ClientId"];
if (!consoleAndAngularClientId.IsNullOrWhiteSpace())
{
var webClientRootUrl = configurationSection["MyProjectName_App:RootUrl"]?.TrimEnd('/');
await CreateClientAsync(
name: consoleAndAngularClientId,
scopes: commonScopes,
grantTypes: new[] { "password", "client_credentials", "authorization_code" },
secret: (configurationSection["MyProjectName_App:ClientSecret"] ?? "1q2w3e*").Sha256(),
requireClientSecret: false,
redirectUri: webClientRootUrl,
postLogoutRedirectUri: webClientRootUrl,
corsOrigins: new[] { webClientRootUrl.RemovePostFix("/") }
);
}
//<TEMPLATE-REMOVE IF-NOT='ui:blazor'>
// Blazor Client //Console Test / Angular Client
var blazorClientId = configurationSection["MyProjectName_Blazor:ClientId"]; var consoleAndAngularClientId = configurationSection["MyProjectName_App:ClientId"];
if (!blazorClientId.IsNullOrWhiteSpace()) if (!consoleAndAngularClientId.IsNullOrWhiteSpace())
{ {
var blazorRootUrl = configurationSection["MyProjectName_Blazor:RootUrl"].TrimEnd('/'); var webClientRootUrl = configurationSection["MyProjectName_App:RootUrl"]?.TrimEnd('/');
await CreateClientAsync( await CreateClientAsync(
name: blazorClientId, name: consoleAndAngularClientId,
scopes: commonScopes, scopes: commonScopes,
grantTypes: new[] { "authorization_code" }, grantTypes: new[] { "password", "client_credentials", "authorization_code" },
secret: configurationSection["MyProjectName_Blazor:ClientSecret"]?.Sha256(), secret: (configurationSection["MyProjectName_App:ClientSecret"] ?? "1q2w3e*").Sha256(),
requireClientSecret: false, requireClientSecret: false,
redirectUri: $"{blazorRootUrl}/authentication/login-callback", redirectUri: webClientRootUrl,
postLogoutRedirectUri: $"{blazorRootUrl}/authentication/logout-callback", postLogoutRedirectUri: webClientRootUrl,
corsOrigins: new[] { blazorRootUrl.RemovePostFix("/") } corsOrigins: new[] { webClientRootUrl.RemovePostFix("/") }
); );
} }
//</TEMPLATE-REMOVE>
//<TEMPLATE-REMOVE IF-NOT='ui:blazor-server&&tiered'>
//Blazor Server Tiered Client
var blazorServerTieredClientId = configurationSection["MyProjectName_BlazorServerTiered:ClientId"];
if (!blazorServerTieredClientId.IsNullOrWhiteSpace())
{
var blazorServerTieredClientRootUrl = configurationSection["MyProjectName_BlazorServerTiered:RootUrl"].EnsureEndsWith('/');
/* MyProjectName_BlazorServerTiered client is only needed if you created a tiered blazor server
* solution. Otherwise, you can delete this client. */
await CreateClientAsync(
name: blazorServerTieredClientId,
scopes: commonScopes,
grantTypes: new[] { "hybrid" },
secret: (configurationSection["MyProjectName_BlazorServerTiered:ClientSecret"] ?? "1q2w3e*").Sha256(),
redirectUri: $"{blazorServerTieredClientRootUrl}signin-oidc",
postLogoutRedirectUri: $"{blazorServerTieredClientRootUrl}signout-callback-oidc",
frontChannelLogoutUri: $"{blazorServerTieredClientRootUrl}Account/FrontChannelLogout",
corsOrigins: new[] { blazorServerTieredClientRootUrl.RemovePostFix("/") }
);
}
//</TEMPLATE-REMOVE> //<TEMPLATE-REMOVE IF-NOT='ui:blazor'>
// Swagger Client // Blazor Client
var swaggerClientId = configurationSection["MyProjectName_Swagger:ClientId"]; var blazorClientId = configurationSection["MyProjectName_Blazor:ClientId"];
if (!swaggerClientId.IsNullOrWhiteSpace()) if (!blazorClientId.IsNullOrWhiteSpace())
{ {
var swaggerRootUrl = configurationSection["MyProjectName_Swagger:RootUrl"].TrimEnd('/'); var blazorRootUrl = configurationSection["MyProjectName_Blazor:RootUrl"].TrimEnd('/');
await CreateClientAsync( await CreateClientAsync(
name: swaggerClientId, name: blazorClientId,
scopes: commonScopes, scopes: commonScopes,
grantTypes: new[] { "authorization_code" }, grantTypes: new[] { "authorization_code" },
secret: configurationSection["MyProjectName_Swagger:ClientSecret"]?.Sha256(), secret: configurationSection["MyProjectName_Blazor:ClientSecret"]?.Sha256(),
requireClientSecret: false, requireClientSecret: false,
redirectUri: $"{swaggerRootUrl}/swagger/oauth2-redirect.html", redirectUri: $"{blazorRootUrl}/authentication/login-callback",
corsOrigins: new[] { swaggerRootUrl.RemovePostFix("/") } postLogoutRedirectUri: $"{blazorRootUrl}/authentication/logout-callback",
); corsOrigins: new[] { blazorRootUrl.RemovePostFix("/") }
} );
}
//</TEMPLATE-REMOVE>
//<TEMPLATE-REMOVE IF-NOT='ui:blazor-server&&tiered'>
//Blazor Server Tiered Client
var blazorServerTieredClientId = configurationSection["MyProjectName_BlazorServerTiered:ClientId"];
if (!blazorServerTieredClientId.IsNullOrWhiteSpace())
{
var blazorServerTieredClientRootUrl = configurationSection["MyProjectName_BlazorServerTiered:RootUrl"].EnsureEndsWith('/');
/* MyProjectName_BlazorServerTiered client is only needed if you created a tiered blazor server
* solution. Otherwise, you can delete this client. */
await CreateClientAsync(
name: blazorServerTieredClientId,
scopes: commonScopes,
grantTypes: new[] { "hybrid" },
secret: (configurationSection["MyProjectName_BlazorServerTiered:ClientSecret"] ?? "1q2w3e*").Sha256(),
redirectUri: $"{blazorServerTieredClientRootUrl}signin-oidc",
postLogoutRedirectUri: $"{blazorServerTieredClientRootUrl}signout-callback-oidc",
frontChannelLogoutUri: $"{blazorServerTieredClientRootUrl}Account/FrontChannelLogout",
corsOrigins: new[] { blazorServerTieredClientRootUrl.RemovePostFix("/") }
);
} }
private async Task<Client> CreateClientAsync( //</TEMPLATE-REMOVE>
string name,
IEnumerable<string> scopes, // Swagger Client
IEnumerable<string> grantTypes, var swaggerClientId = configurationSection["MyProjectName_Swagger:ClientId"];
string secret = null, if (!swaggerClientId.IsNullOrWhiteSpace())
string redirectUri = null,
string postLogoutRedirectUri = null,
string frontChannelLogoutUri = null,
bool requireClientSecret = true,
bool requirePkce = false,
IEnumerable<string> permissions = null,
IEnumerable<string> corsOrigins = null)
{ {
var client = await _clientRepository.FindByClientIdAsync(name); var swaggerRootUrl = configurationSection["MyProjectName_Swagger:RootUrl"].TrimEnd('/');
if (client == null)
{ await CreateClientAsync(
client = await _clientRepository.InsertAsync( name: swaggerClientId,
new Client( scopes: commonScopes,
_guidGenerator.Create(), grantTypes: new[] { "authorization_code" },
name secret: configurationSection["MyProjectName_Swagger:ClientSecret"]?.Sha256(),
) requireClientSecret: false,
{ redirectUri: $"{swaggerRootUrl}/swagger/oauth2-redirect.html",
ClientName = name, corsOrigins: new[] { swaggerRootUrl.RemovePostFix("/") }
ProtocolType = "oidc", );
Description = name, }
AlwaysIncludeUserClaimsInIdToken = true, }
AllowOfflineAccess = true,
AbsoluteRefreshTokenLifetime = 31536000, //365 days private async Task<Client> CreateClientAsync(
string name,
IEnumerable<string> scopes,
IEnumerable<string> grantTypes,
string secret = null,
string redirectUri = null,
string postLogoutRedirectUri = null,
string frontChannelLogoutUri = null,
bool requireClientSecret = true,
bool requirePkce = false,
IEnumerable<string> permissions = null,
IEnumerable<string> corsOrigins = null)
{
var client = await _clientRepository.FindByClientIdAsync(name);
if (client == null)
{
client = await _clientRepository.InsertAsync(
new Client(
_guidGenerator.Create(),
name
)
{
ClientName = name,
ProtocolType = "oidc",
Description = name,
AlwaysIncludeUserClaimsInIdToken = true,
AllowOfflineAccess = true,
AbsoluteRefreshTokenLifetime = 31536000, //365 days
AccessTokenLifetime = 31536000, //365 days AccessTokenLifetime = 31536000, //365 days
AuthorizationCodeLifetime = 300, AuthorizationCodeLifetime = 300,
IdentityTokenLifetime = 300, IdentityTokenLifetime = 300,
RequireConsent = false, RequireConsent = false,
FrontChannelLogoutUri = frontChannelLogoutUri, FrontChannelLogoutUri = frontChannelLogoutUri,
RequireClientSecret = requireClientSecret, RequireClientSecret = requireClientSecret,
RequirePkce = requirePkce RequirePkce = requirePkce
}, },
autoSave: true autoSave: true
); );
} }
foreach (var scope in scopes) foreach (var scope in scopes)
{
if (client.FindScope(scope) == null)
{ {
if (client.FindScope(scope) == null) client.AddScope(scope);
{
client.AddScope(scope);
}
} }
}
foreach (var grantType in grantTypes) foreach (var grantType in grantTypes)
{
if (client.FindGrantType(grantType) == null)
{ {
if (client.FindGrantType(grantType) == null) client.AddGrantType(grantType);
{
client.AddGrantType(grantType);
}
} }
}
if (!secret.IsNullOrEmpty()) if (!secret.IsNullOrEmpty())
{
if (client.FindSecret(secret) == null)
{ {
if (client.FindSecret(secret) == null) client.AddSecret(secret);
{
client.AddSecret(secret);
}
} }
}
if (redirectUri != null) if (redirectUri != null)
{
if (client.FindRedirectUri(redirectUri) == null)
{ {
if (client.FindRedirectUri(redirectUri) == null) client.AddRedirectUri(redirectUri);
{
client.AddRedirectUri(redirectUri);
}
} }
}
if (postLogoutRedirectUri != null) if (postLogoutRedirectUri != null)
{
if (client.FindPostLogoutRedirectUri(postLogoutRedirectUri) == null)
{ {
if (client.FindPostLogoutRedirectUri(postLogoutRedirectUri) == null) client.AddPostLogoutRedirectUri(postLogoutRedirectUri);
{
client.AddPostLogoutRedirectUri(postLogoutRedirectUri);
}
} }
}
if (permissions != null) if (permissions != null)
{ {
await _permissionDataSeeder.SeedAsync( await _permissionDataSeeder.SeedAsync(
ClientPermissionValueProvider.ProviderName, ClientPermissionValueProvider.ProviderName,
name, name,
permissions, permissions,
null null
); );
} }
if (corsOrigins != null) if (corsOrigins != null)
{
foreach (var origin in corsOrigins)
{ {
foreach (var origin in corsOrigins) if (!origin.IsNullOrWhiteSpace() && client.FindCorsOrigin(origin) == null)
{ {
if (!origin.IsNullOrWhiteSpace() && client.FindCorsOrigin(origin) == null) client.AddCorsOrigin(origin);
{
client.AddCorsOrigin(origin);
}
} }
} }
return await _clientRepository.UpdateAsync(client);
} }
return await _clientRepository.UpdateAsync(client);
} }
} }

11
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/MyProjectNameConsts.cs

@ -1,9 +1,8 @@
namespace MyCompanyName.MyProjectName namespace MyCompanyName.MyProjectName;
public static class MyProjectNameConsts
{ {
public static class MyProjectNameConsts public const string DbTablePrefix = "App";
{
public const string DbTablePrefix = "App";
public const string DbSchema = null; public const string DbSchema = null;
}
} }

43
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/MyProjectNameDomainModule.cs

@ -14,33 +14,32 @@ using Volo.Abp.PermissionManagement.IdentityServer;
using Volo.Abp.SettingManagement; using Volo.Abp.SettingManagement;
using Volo.Abp.TenantManagement; using Volo.Abp.TenantManagement;
namespace MyCompanyName.MyProjectName namespace MyCompanyName.MyProjectName;
[DependsOn(
typeof(MyProjectNameDomainSharedModule),
typeof(AbpAuditLoggingDomainModule),
typeof(AbpBackgroundJobsDomainModule),
typeof(AbpFeatureManagementDomainModule),
typeof(AbpIdentityDomainModule),
typeof(AbpPermissionManagementDomainIdentityModule),
typeof(AbpIdentityServerDomainModule),
typeof(AbpPermissionManagementDomainIdentityServerModule),
typeof(AbpSettingManagementDomainModule),
typeof(AbpTenantManagementDomainModule),
typeof(AbpEmailingModule)
)]
public class MyProjectNameDomainModule : AbpModule
{ {
[DependsOn( public override void ConfigureServices(ServiceConfigurationContext context)
typeof(MyProjectNameDomainSharedModule),
typeof(AbpAuditLoggingDomainModule),
typeof(AbpBackgroundJobsDomainModule),
typeof(AbpFeatureManagementDomainModule),
typeof(AbpIdentityDomainModule),
typeof(AbpPermissionManagementDomainIdentityModule),
typeof(AbpIdentityServerDomainModule),
typeof(AbpPermissionManagementDomainIdentityServerModule),
typeof(AbpSettingManagementDomainModule),
typeof(AbpTenantManagementDomainModule),
typeof(AbpEmailingModule)
)]
public class MyProjectNameDomainModule : AbpModule
{ {
public override void ConfigureServices(ServiceConfigurationContext context) Configure<AbpMultiTenancyOptions>(options =>
{ {
Configure<AbpMultiTenancyOptions>(options => options.IsEnabled = MultiTenancyConsts.IsEnabled;
{ });
options.IsEnabled = MultiTenancyConsts.IsEnabled;
});
#if DEBUG #if DEBUG
context.Services.Replace(ServiceDescriptor.Singleton<IEmailSender, NullEmailSender>()); context.Services.Replace(ServiceDescriptor.Singleton<IEmailSender, NullEmailSender>());
#endif #endif
}
} }
} }

13
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Settings/MyProjectNameSettingDefinitionProvider.cs

@ -1,13 +1,12 @@
using Volo.Abp.Settings; using Volo.Abp.Settings;
namespace MyCompanyName.MyProjectName.Settings namespace MyCompanyName.MyProjectName.Settings;
public class MyProjectNameSettingDefinitionProvider : SettingDefinitionProvider
{ {
public class MyProjectNameSettingDefinitionProvider : SettingDefinitionProvider public override void Define(ISettingDefinitionContext context)
{ {
public override void Define(ISettingDefinitionContext context) //Define your own settings here. Example:
{ //context.Add(new SettingDefinition(MyProjectNameSettings.MySetting1));
//Define your own settings here. Example:
//context.Add(new SettingDefinition(MyProjectNameSettings.MySetting1));
}
} }
} }

15
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Settings/MyProjectNameSettings.cs

@ -1,10 +1,9 @@
namespace MyCompanyName.MyProjectName.Settings namespace MyCompanyName.MyProjectName.Settings;
public static class MyProjectNameSettings
{ {
public static class MyProjectNameSettings private const string Prefix = "MyProjectName";
{
private const string Prefix = "MyProjectName";
//Add your own setting names here. Example: //Add your own setting names here. Example:
//public const string MySetting1 = Prefix + ".MySetting1"; //public const string MySetting1 = Prefix + ".MySetting1";
} }
}

43
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/EntityFrameworkCoreMyProjectNameDbSchemaMigrator.cs

@ -5,31 +5,30 @@ using Microsoft.Extensions.DependencyInjection;
using MyCompanyName.MyProjectName.Data; using MyCompanyName.MyProjectName.Data;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
namespace MyCompanyName.MyProjectName.EntityFrameworkCore namespace MyCompanyName.MyProjectName.EntityFrameworkCore;
public class EntityFrameworkCoreMyProjectNameDbSchemaMigrator
: IMyProjectNameDbSchemaMigrator, ITransientDependency
{ {
public class EntityFrameworkCoreMyProjectNameDbSchemaMigrator private readonly IServiceProvider _serviceProvider;
: IMyProjectNameDbSchemaMigrator, ITransientDependency
{
private readonly IServiceProvider _serviceProvider;
public EntityFrameworkCoreMyProjectNameDbSchemaMigrator( public EntityFrameworkCoreMyProjectNameDbSchemaMigrator(
IServiceProvider serviceProvider) IServiceProvider serviceProvider)
{ {
_serviceProvider = serviceProvider; _serviceProvider = serviceProvider;
} }
public async Task MigrateAsync() public async Task MigrateAsync()
{ {
/* We intentionally resolving the MyProjectNameDbContext /* We intentionally resolving the MyProjectNameDbContext
* from IServiceProvider (instead of directly injecting it) * from IServiceProvider (instead of directly injecting it)
* to properly get the connection string of the current tenant in the * to properly get the connection string of the current tenant in the
* current scope. * current scope.
*/ */
await _serviceProvider await _serviceProvider
.GetRequiredService<MyProjectNameDbContext>() .GetRequiredService<MyProjectNameDbContext>()
.Database .Database
.MigrateAsync(); .MigrateAsync();
}
} }
} }

121
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContext.cs

@ -13,74 +13,73 @@ using Volo.Abp.SettingManagement.EntityFrameworkCore;
using Volo.Abp.TenantManagement; using Volo.Abp.TenantManagement;
using Volo.Abp.TenantManagement.EntityFrameworkCore; using Volo.Abp.TenantManagement.EntityFrameworkCore;
namespace MyCompanyName.MyProjectName.EntityFrameworkCore namespace MyCompanyName.MyProjectName.EntityFrameworkCore;
[ReplaceDbContext(typeof(IIdentityDbContext))]
[ReplaceDbContext(typeof(ITenantManagementDbContext))]
[ConnectionStringName("Default")]
public class MyProjectNameDbContext :
AbpDbContext<MyProjectNameDbContext>,
IIdentityDbContext,
ITenantManagementDbContext
{ {
[ReplaceDbContext(typeof(IIdentityDbContext))] /* Add DbSet properties for your Aggregate Roots / Entities here. */
[ReplaceDbContext(typeof(ITenantManagementDbContext))]
[ConnectionStringName("Default")] #region Entities from the modules
public class MyProjectNameDbContext :
AbpDbContext<MyProjectNameDbContext>, /* Notice: We only implemented IIdentityDbContext and ITenantManagementDbContext
IIdentityDbContext, * and replaced them for this DbContext. This allows you to perform JOIN
ITenantManagementDbContext * queries for the entities of these modules over the repositories easily. You
{ * typically don't need that for other modules. But, if you need, you can
/* Add DbSet properties for your Aggregate Roots / Entities here. */ * implement the DbContext interface of the needed module and use ReplaceDbContext
* attribute just like IIdentityDbContext and ITenantManagementDbContext.
#region Entities from the modules *
* More info: Replacing a DbContext of a module ensures that the related module
/* Notice: We only implemented IIdentityDbContext and ITenantManagementDbContext * uses this DbContext on runtime. Otherwise, it will use its own DbContext class.
* and replaced them for this DbContext. This allows you to perform JOIN */
* queries for the entities of these modules over the repositories easily. You
* typically don't need that for other modules. But, if you need, you can //Identity
* implement the DbContext interface of the needed module and use ReplaceDbContext public DbSet<IdentityUser> Users { get; set; }
* attribute just like IIdentityDbContext and ITenantManagementDbContext. public DbSet<IdentityRole> Roles { get; set; }
* public DbSet<IdentityClaimType> ClaimTypes { get; set; }
* More info: Replacing a DbContext of a module ensures that the related module public DbSet<OrganizationUnit> OrganizationUnits { get; set; }
* uses this DbContext on runtime. Otherwise, it will use its own DbContext class. public DbSet<IdentitySecurityLog> SecurityLogs { get; set; }
*/ public DbSet<IdentityLinkUser> LinkUsers { get; set; }
//Identity
public DbSet<IdentityUser> Users { get; set; }
public DbSet<IdentityRole> Roles { get; set; }
public DbSet<IdentityClaimType> ClaimTypes { get; set; }
public DbSet<OrganizationUnit> OrganizationUnits { get; set; }
public DbSet<IdentitySecurityLog> SecurityLogs { get; set; }
public DbSet<IdentityLinkUser> LinkUsers { get; set; }
// Tenant Management
public DbSet<Tenant> Tenants { get; set; }
public DbSet<TenantConnectionString> TenantConnectionStrings { get; set; }
#endregion // Tenant Management
public DbSet<Tenant> Tenants { get; set; }
public MyProjectNameDbContext(DbContextOptions<MyProjectNameDbContext> options) public DbSet<TenantConnectionString> TenantConnectionStrings { get; set; }
: base(options)
{
} #endregion
protected override void OnModelCreating(ModelBuilder builder) public MyProjectNameDbContext(DbContextOptions<MyProjectNameDbContext> options)
{ : base(options)
base.OnModelCreating(builder); {
}
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
/* Include modules to your migration db context */ /* Include modules to your migration db context */
builder.ConfigurePermissionManagement(); builder.ConfigurePermissionManagement();
builder.ConfigureSettingManagement(); builder.ConfigureSettingManagement();
builder.ConfigureBackgroundJobs(); builder.ConfigureBackgroundJobs();
builder.ConfigureAuditLogging(); builder.ConfigureAuditLogging();
builder.ConfigureIdentity(); builder.ConfigureIdentity();
builder.ConfigureIdentityServer(); builder.ConfigureIdentityServer();
builder.ConfigureFeatureManagement(); builder.ConfigureFeatureManagement();
builder.ConfigureTenantManagement(); builder.ConfigureTenantManagement();
/* Configure your own tables/entities inside here */ /* Configure your own tables/entities inside here */
//builder.Entity<YourEntity>(b => //builder.Entity<YourEntity>(b =>
//{ //{
// b.ToTable(MyProjectNameConsts.DbTablePrefix + "YourEntities", MyProjectNameConsts.DbSchema); // b.ToTable(MyProjectNameConsts.DbTablePrefix + "YourEntities", MyProjectNameConsts.DbSchema);
// b.ConfigureByConvention(); //auto configure for the base class props // b.ConfigureByConvention(); //auto configure for the base class props
// //... // //...
//}); //});
}
} }
} }

37
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContextFactory.cs

@ -3,31 +3,30 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design; using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
namespace MyCompanyName.MyProjectName.EntityFrameworkCore namespace MyCompanyName.MyProjectName.EntityFrameworkCore;
/* This class is needed for EF Core console commands
* (like Add-Migration and Update-Database commands) */
public class MyProjectNameDbContextFactory : IDesignTimeDbContextFactory<MyProjectNameDbContext>
{ {
/* This class is needed for EF Core console commands public MyProjectNameDbContext CreateDbContext(string[] args)
* (like Add-Migration and Update-Database commands) */
public class MyProjectNameDbContextFactory : IDesignTimeDbContextFactory<MyProjectNameDbContext>
{ {
public MyProjectNameDbContext CreateDbContext(string[] args) MyProjectNameEfCoreEntityExtensionMappings.Configure();
{
MyProjectNameEfCoreEntityExtensionMappings.Configure();
var configuration = BuildConfiguration(); var configuration = BuildConfiguration();
var builder = new DbContextOptionsBuilder<MyProjectNameDbContext>() var builder = new DbContextOptionsBuilder<MyProjectNameDbContext>()
.UseSqlServer(configuration.GetConnectionString("Default")); .UseSqlServer(configuration.GetConnectionString("Default"));
return new MyProjectNameDbContext(builder.Options); return new MyProjectNameDbContext(builder.Options);
} }
private static IConfigurationRoot BuildConfiguration() private static IConfigurationRoot BuildConfiguration()
{ {
var builder = new ConfigurationBuilder() var builder = new ConfigurationBuilder()
.SetBasePath(Path.Combine(Directory.GetCurrentDirectory(), "../MyCompanyName.MyProjectName.DbMigrator/")) .SetBasePath(Path.Combine(Directory.GetCurrentDirectory(), "../MyCompanyName.MyProjectName.DbMigrator/"))
.AddJsonFile("appsettings.json", optional: false); .AddJsonFile("appsettings.json", optional: false);
return builder.Build(); return builder.Build();
}
} }
} }

21
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameEfCoreEntityExtensionMappings.cs

@ -3,19 +3,19 @@ using Volo.Abp.Identity;
using Volo.Abp.ObjectExtending; using Volo.Abp.ObjectExtending;
using Volo.Abp.Threading; using Volo.Abp.Threading;
namespace MyCompanyName.MyProjectName.EntityFrameworkCore namespace MyCompanyName.MyProjectName.EntityFrameworkCore;
public static class MyProjectNameEfCoreEntityExtensionMappings
{ {
public static class MyProjectNameEfCoreEntityExtensionMappings private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner();
public static void Configure()
{ {
private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner(); MyProjectNameGlobalFeatureConfigurator.Configure();
MyProjectNameModuleExtensionConfigurator.Configure();
public static void Configure() OneTimeRunner.Run(() =>
{ {
MyProjectNameGlobalFeatureConfigurator.Configure();
MyProjectNameModuleExtensionConfigurator.Configure();
OneTimeRunner.Run(() =>
{
/* You can configure extra properties for the /* You can configure extra properties for the
* entities defined in the modules used by your application. * entities defined in the modules used by your application.
* *
@ -39,7 +39,6 @@ namespace MyCompanyName.MyProjectName.EntityFrameworkCore
* See the documentation for more: * See the documentation for more:
* https://docs.abp.io/en/abp/latest/Customizing-Application-Modules-Extending-Entities * https://docs.abp.io/en/abp/latest/Customizing-Application-Modules-Extending-Entities
*/ */
}); });
}
} }
} }

55
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreModule.cs

@ -11,42 +11,41 @@ using Volo.Abp.PermissionManagement.EntityFrameworkCore;
using Volo.Abp.SettingManagement.EntityFrameworkCore; using Volo.Abp.SettingManagement.EntityFrameworkCore;
using Volo.Abp.TenantManagement.EntityFrameworkCore; using Volo.Abp.TenantManagement.EntityFrameworkCore;
namespace MyCompanyName.MyProjectName.EntityFrameworkCore namespace MyCompanyName.MyProjectName.EntityFrameworkCore;
[DependsOn(
typeof(MyProjectNameDomainModule),
typeof(AbpIdentityEntityFrameworkCoreModule),
typeof(AbpIdentityServerEntityFrameworkCoreModule),
typeof(AbpPermissionManagementEntityFrameworkCoreModule),
typeof(AbpSettingManagementEntityFrameworkCoreModule),
typeof(AbpEntityFrameworkCoreSqlServerModule),
typeof(AbpBackgroundJobsEntityFrameworkCoreModule),
typeof(AbpAuditLoggingEntityFrameworkCoreModule),
typeof(AbpTenantManagementEntityFrameworkCoreModule),
typeof(AbpFeatureManagementEntityFrameworkCoreModule)
)]
public class MyProjectNameEntityFrameworkCoreModule : AbpModule
{ {
[DependsOn( public override void PreConfigureServices(ServiceConfigurationContext context)
typeof(MyProjectNameDomainModule),
typeof(AbpIdentityEntityFrameworkCoreModule),
typeof(AbpIdentityServerEntityFrameworkCoreModule),
typeof(AbpPermissionManagementEntityFrameworkCoreModule),
typeof(AbpSettingManagementEntityFrameworkCoreModule),
typeof(AbpEntityFrameworkCoreSqlServerModule),
typeof(AbpBackgroundJobsEntityFrameworkCoreModule),
typeof(AbpAuditLoggingEntityFrameworkCoreModule),
typeof(AbpTenantManagementEntityFrameworkCoreModule),
typeof(AbpFeatureManagementEntityFrameworkCoreModule)
)]
public class MyProjectNameEntityFrameworkCoreModule : AbpModule
{ {
public override void PreConfigureServices(ServiceConfigurationContext context) MyProjectNameEfCoreEntityExtensionMappings.Configure();
{ }
MyProjectNameEfCoreEntityExtensionMappings.Configure();
}
public override void ConfigureServices(ServiceConfigurationContext context) public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAbpDbContext<MyProjectNameDbContext>(options =>
{ {
context.Services.AddAbpDbContext<MyProjectNameDbContext>(options =>
{
/* Remove "includeAllEntities: true" to create /* Remove "includeAllEntities: true" to create
* default repositories only for aggregate roots */ * default repositories only for aggregate roots */
options.AddDefaultRepositories(includeAllEntities: true); options.AddDefaultRepositories(includeAllEntities: true);
}); });
Configure<AbpDbContextOptions>(options => Configure<AbpDbContextOptions>(options =>
{ {
/* The main point to change your DBMS. /* The main point to change your DBMS.
* See also MyProjectNameMigrationsDbContextFactory for EF Core tooling. */ * See also MyProjectNameMigrationsDbContextFactory for EF Core tooling. */
options.UseSqlServer(); options.UseSqlServer();
}); });
}
} }
} }

2583
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20211105125915_Initial.cs

File diff suppressed because it is too large

45
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Client/MyProjectNameHttpApiClientModule.cs

@ -8,32 +8,31 @@ using Volo.Abp.TenantManagement;
using Volo.Abp.SettingManagement; using Volo.Abp.SettingManagement;
using Volo.Abp.VirtualFileSystem; using Volo.Abp.VirtualFileSystem;
namespace MyCompanyName.MyProjectName namespace MyCompanyName.MyProjectName;
[DependsOn(
typeof(MyProjectNameApplicationContractsModule),
typeof(AbpAccountHttpApiClientModule),
typeof(AbpIdentityHttpApiClientModule),
typeof(AbpPermissionManagementHttpApiClientModule),
typeof(AbpTenantManagementHttpApiClientModule),
typeof(AbpFeatureManagementHttpApiClientModule),
typeof(AbpSettingManagementHttpApiClientModule)
)]
public class MyProjectNameHttpApiClientModule : AbpModule
{ {
[DependsOn( public const string RemoteServiceName = "Default";
typeof(MyProjectNameApplicationContractsModule),
typeof(AbpAccountHttpApiClientModule), public override void ConfigureServices(ServiceConfigurationContext context)
typeof(AbpIdentityHttpApiClientModule),
typeof(AbpPermissionManagementHttpApiClientModule),
typeof(AbpTenantManagementHttpApiClientModule),
typeof(AbpFeatureManagementHttpApiClientModule),
typeof(AbpSettingManagementHttpApiClientModule)
)]
public class MyProjectNameHttpApiClientModule : AbpModule
{ {
public const string RemoteServiceName = "Default"; context.Services.AddHttpClientProxies(
typeof(MyProjectNameApplicationContractsModule).Assembly,
RemoteServiceName
);
public override void ConfigureServices(ServiceConfigurationContext context) Configure<AbpVirtualFileSystemOptions>(options =>
{ {
context.Services.AddHttpClientProxies( options.FileSets.AddEmbedded<MyProjectNameHttpApiClientModule>();
typeof(MyProjectNameApplicationContractsModule).Assembly, });
RemoteServiceName
);
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<MyProjectNameHttpApiClientModule>();
});
}
} }
} }

11
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/Controllers/HomeController.cs

@ -1,13 +1,12 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc;
namespace MyCompanyName.MyProjectName.Controllers namespace MyCompanyName.MyProjectName.Controllers;
public class HomeController : AbpController
{ {
public class HomeController : AbpController public ActionResult Index()
{ {
public ActionResult Index() return Redirect("~/swagger");
{
return Redirect("~/swagger");
}
} }
} }

329
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs

@ -27,199 +27,198 @@ using Volo.Abp.Modularity;
using Volo.Abp.Swashbuckle; using Volo.Abp.Swashbuckle;
using Volo.Abp.VirtualFileSystem; using Volo.Abp.VirtualFileSystem;
namespace MyCompanyName.MyProjectName namespace MyCompanyName.MyProjectName;
[DependsOn(
typeof(MyProjectNameHttpApiModule),
typeof(AbpAutofacModule),
typeof(AbpCachingStackExchangeRedisModule),
typeof(AbpAspNetCoreMvcUiMultiTenancyModule),
typeof(MyProjectNameApplicationModule),
typeof(MyProjectNameEntityFrameworkCoreModule),
typeof(AbpAspNetCoreSerilogModule),
typeof(AbpSwashbuckleModule)
)]
public class MyProjectNameHttpApiHostModule : AbpModule
{ {
[DependsOn( public override void ConfigureServices(ServiceConfigurationContext context)
typeof(MyProjectNameHttpApiModule),
typeof(AbpAutofacModule),
typeof(AbpCachingStackExchangeRedisModule),
typeof(AbpAspNetCoreMvcUiMultiTenancyModule),
typeof(MyProjectNameApplicationModule),
typeof(MyProjectNameEntityFrameworkCoreModule),
typeof(AbpAspNetCoreSerilogModule),
typeof(AbpSwashbuckleModule)
)]
public class MyProjectNameHttpApiHostModule : AbpModule
{ {
public override void ConfigureServices(ServiceConfigurationContext context) var configuration = context.Services.GetConfiguration();
{ var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.GetConfiguration();
var hostingEnvironment = context.Services.GetHostingEnvironment(); ConfigureConventionalControllers();
ConfigureAuthentication(context, configuration);
ConfigureConventionalControllers(); ConfigureLocalization();
ConfigureAuthentication(context, configuration); ConfigureCache(configuration);
ConfigureLocalization(); ConfigureVirtualFileSystem(context);
ConfigureCache(configuration); ConfigureDataProtection(context, configuration, hostingEnvironment);
ConfigureVirtualFileSystem(context); ConfigureCors(context, configuration);
ConfigureDataProtection(context, configuration, hostingEnvironment); ConfigureSwaggerServices(context, configuration);
ConfigureCors(context, configuration); }
ConfigureSwaggerServices(context, configuration);
}
private void ConfigureCache(IConfiguration configuration)
{
Configure<AbpDistributedCacheOptions>(options => { options.KeyPrefix = "MyProjectName:"; });
}
private void ConfigureVirtualFileSystem(ServiceConfigurationContext context) private void ConfigureCache(IConfiguration configuration)
{ {
var hostingEnvironment = context.Services.GetHostingEnvironment(); Configure<AbpDistributedCacheOptions>(options => { options.KeyPrefix = "MyProjectName:"; });
}
if (hostingEnvironment.IsDevelopment()) private void ConfigureVirtualFileSystem(ServiceConfigurationContext context)
{ {
Configure<AbpVirtualFileSystemOptions>(options => var hostingEnvironment = context.Services.GetHostingEnvironment();
{
options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameDomainSharedModule>(
Path.Combine(hostingEnvironment.ContentRootPath,
$"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain.Shared"));
options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameDomainModule>(
Path.Combine(hostingEnvironment.ContentRootPath,
$"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain"));
options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameApplicationContractsModule>(
Path.Combine(hostingEnvironment.ContentRootPath,
$"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Application.Contracts"));
options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameApplicationModule>(
Path.Combine(hostingEnvironment.ContentRootPath,
$"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Application"));
});
}
}
private void ConfigureConventionalControllers() if (hostingEnvironment.IsDevelopment())
{ {
Configure<AbpAspNetCoreMvcOptions>(options => Configure<AbpVirtualFileSystemOptions>(options =>
{ {
options.ConventionalControllers.Create(typeof(MyProjectNameApplicationModule).Assembly); options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameDomainSharedModule>(
Path.Combine(hostingEnvironment.ContentRootPath,
$"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain.Shared"));
options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameDomainModule>(
Path.Combine(hostingEnvironment.ContentRootPath,
$"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain"));
options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameApplicationContractsModule>(
Path.Combine(hostingEnvironment.ContentRootPath,
$"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Application.Contracts"));
options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameApplicationModule>(
Path.Combine(hostingEnvironment.ContentRootPath,
$"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Application"));
}); });
} }
}
private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration) private void ConfigureConventionalControllers()
{
Configure<AbpAspNetCoreMvcOptions>(options =>
{ {
context.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) options.ConventionalControllers.Create(typeof(MyProjectNameApplicationModule).Assembly);
.AddJwtBearer(options => });
{ }
options.Authority = configuration["AuthServer:Authority"];
options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]);
options.Audience = "MyProjectName";
});
}
private static void ConfigureSwaggerServices(ServiceConfigurationContext context, IConfiguration configuration) private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration)
{ {
context.Services.AddAbpSwaggerGenWithOAuth( context.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
configuration["AuthServer:Authority"], .AddJwtBearer(options =>
new Dictionary<string, string> {
{ options.Authority = configuration["AuthServer:Authority"];
{"MyProjectName", "MyProjectName API"} options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]);
}, options.Audience = "MyProjectName";
options => });
{ }
options.SwaggerDoc("v1", new OpenApiInfo {Title = "MyProjectName API", Version = "v1"});
options.DocInclusionPredicate((docName, description) => true);
options.CustomSchemaIds(type => type.FullName);
});
}
private void ConfigureLocalization() private static void ConfigureSwaggerServices(ServiceConfigurationContext context, IConfiguration configuration)
{ {
Configure<AbpLocalizationOptions>(options => context.Services.AddAbpSwaggerGenWithOAuth(
configuration["AuthServer:Authority"],
new Dictionary<string, string>
{ {
options.Languages.Add(new LanguageInfo("ar", "ar", "العربية")); {"MyProjectName", "MyProjectName API"}
options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština")); },
options.Languages.Add(new LanguageInfo("en", "en", "English")); options =>
options.Languages.Add(new LanguageInfo("en-GB", "en-GB", "English (UK)")); {
options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish")); options.SwaggerDoc("v1", new OpenApiInfo { Title = "MyProjectName API", Version = "v1" });
options.Languages.Add(new LanguageInfo("fr", "fr", "Français")); options.DocInclusionPredicate((docName, description) => true);
options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in")); options.CustomSchemaIds(type => type.FullName);
options.Languages.Add(new LanguageInfo("is", "is", "Icelandic", "is"));
options.Languages.Add(new LanguageInfo("it", "it", "Italiano", "it"));
options.Languages.Add(new LanguageInfo("ro-RO", "ro-RO", "Română"));
options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar"));
options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português"));
options.Languages.Add(new LanguageInfo("ru", "ru", "Русский"));
options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak"));
options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe"));
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文"));
options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文"));
options.Languages.Add(new LanguageInfo("de-DE", "de-DE", "Deutsch", "de"));
options.Languages.Add(new LanguageInfo("es", "es", "Español", "es"));
}); });
} }
private void ConfigureDataProtection( private void ConfigureLocalization()
ServiceConfigurationContext context, {
IConfiguration configuration, Configure<AbpLocalizationOptions>(options =>
IWebHostEnvironment hostingEnvironment)
{ {
var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("MyProjectName"); options.Languages.Add(new LanguageInfo("ar", "ar", "العربية"));
if (!hostingEnvironment.IsDevelopment()) options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština"));
{ options.Languages.Add(new LanguageInfo("en", "en", "English"));
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); options.Languages.Add(new LanguageInfo("en-GB", "en-GB", "English (UK)"));
dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys"); options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish"));
} options.Languages.Add(new LanguageInfo("fr", "fr", "Français"));
} options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in"));
options.Languages.Add(new LanguageInfo("is", "is", "Icelandic", "is"));
options.Languages.Add(new LanguageInfo("it", "it", "Italiano", "it"));
options.Languages.Add(new LanguageInfo("ro-RO", "ro-RO", "Română"));
options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar"));
options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português"));
options.Languages.Add(new LanguageInfo("ru", "ru", "Русский"));
options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak"));
options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe"));
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文"));
options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文"));
options.Languages.Add(new LanguageInfo("de-DE", "de-DE", "Deutsch", "de"));
options.Languages.Add(new LanguageInfo("es", "es", "Español", "es"));
});
}
private void ConfigureCors(ServiceConfigurationContext context, IConfiguration configuration) private void ConfigureDataProtection(
ServiceConfigurationContext context,
IConfiguration configuration,
IWebHostEnvironment hostingEnvironment)
{
var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("MyProjectName");
if (!hostingEnvironment.IsDevelopment())
{ {
context.Services.AddCors(options => var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]);
{ dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys");
options.AddDefaultPolicy(builder =>
{
builder
.WithOrigins(
configuration["App:CorsOrigins"]
.Split(",", StringSplitOptions.RemoveEmptyEntries)
.Select(o => o.RemovePostFix("/"))
.ToArray()
)
.WithAbpExposedHeaders()
.SetIsOriginAllowedToAllowWildcardSubdomains()
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
});
} }
}
public override void OnApplicationInitialization(ApplicationInitializationContext context) private void ConfigureCors(ServiceConfigurationContext context, IConfiguration configuration)
{
context.Services.AddCors(options =>
{ {
var app = context.GetApplicationBuilder(); options.AddDefaultPolicy(builder =>
var env = context.GetEnvironment();
if (env.IsDevelopment())
{ {
app.UseDeveloperExceptionPage(); builder
} .WithOrigins(
configuration["App:CorsOrigins"]
.Split(",", StringSplitOptions.RemoveEmptyEntries)
.Select(o => o.RemovePostFix("/"))
.ToArray()
)
.WithAbpExposedHeaders()
.SetIsOriginAllowedToAllowWildcardSubdomains()
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
});
}
app.UseAbpRequestLocalization(); public override void OnApplicationInitialization(ApplicationInitializationContext context)
app.UseCorrelationId(); {
app.UseStaticFiles(); var app = context.GetApplicationBuilder();
app.UseRouting(); var env = context.GetEnvironment();
app.UseCors();
app.UseAuthentication();
if (MultiTenancyConsts.IsEnabled) if (env.IsDevelopment())
{ {
app.UseMultiTenancy(); app.UseDeveloperExceptionPage();
} }
app.UseAuthorization(); app.UseAbpRequestLocalization();
app.UseCorrelationId();
app.UseStaticFiles();
app.UseRouting();
app.UseCors();
app.UseAuthentication();
app.UseSwagger(); if (MultiTenancyConsts.IsEnabled)
app.UseAbpSwaggerUI(options => {
{ app.UseMultiTenancy();
options.SwaggerEndpoint("/swagger/v1/swagger.json", "MyProjectName API"); }
var configuration = context.GetConfiguration(); app.UseAuthorization();
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);
options.OAuthScopes("MyProjectName");
});
app.UseAuditing(); app.UseSwagger();
app.UseAbpSerilogEnrichers(); app.UseAbpSwaggerUI(options =>
app.UseUnitOfWork(); {
app.UseConfiguredEndpoints(); options.SwaggerEndpoint("/swagger/v1/swagger.json", "MyProjectName API");
}
var configuration = context.GetConfiguration();
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);
options.OAuthScopes("MyProjectName");
});
app.UseAuditing();
app.UseAbpSerilogEnrichers();
app.UseUnitOfWork();
app.UseConfiguredEndpoints();
} }
} }

65
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/Program.cs

@ -5,52 +5,51 @@ using Microsoft.Extensions.Hosting;
using Serilog; using Serilog;
using Serilog.Events; using Serilog.Events;
namespace MyCompanyName.MyProjectName namespace MyCompanyName.MyProjectName;
public class Program
{ {
public class Program public static int Main(string[] args)
{ {
public static int Main(string[] args) Log.Logger = new LoggerConfiguration()
{
Log.Logger = new LoggerConfiguration()
#if DEBUG #if DEBUG
.MinimumLevel.Debug() .MinimumLevel.Debug()
#else #else
.MinimumLevel.Information() .MinimumLevel.Information()
#endif #endif
.MinimumLevel.Override("Microsoft", LogEventLevel.Information) .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) .MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
.Enrich.FromLogContext() .Enrich.FromLogContext()
.WriteTo.Async(c => c.File("Logs/logs.txt")) .WriteTo.Async(c => c.File("Logs/logs.txt"))
#if DEBUG #if DEBUG
.WriteTo.Async(c => c.Console()) .WriteTo.Async(c => c.Console())
#endif #endif
.CreateLogger(); .CreateLogger();
try try
{ {
Log.Information("Starting MyCompanyName.MyProjectName.HttpApi.Host."); Log.Information("Starting MyCompanyName.MyProjectName.HttpApi.Host.");
CreateHostBuilder(args).Build().Run(); CreateHostBuilder(args).Build().Run();
return 0; return 0;
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Fatal(ex, "Host terminated unexpectedly!"); Log.Fatal(ex, "Host terminated unexpectedly!");
return 1; return 1;
} }
finally finally
{ {
Log.CloseAndFlush(); Log.CloseAndFlush();
}
} }
internal static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.AddAppSettingsSecretsJson()
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.UseAutofac()
.UseSerilog();
} }
internal static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.AddAppSettingsSecretsJson()
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.UseAutofac()
.UseSerilog();
} }

19
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/Startup.cs

@ -3,18 +3,17 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace MyCompanyName.MyProjectName namespace MyCompanyName.MyProjectName;
public class Startup
{ {
public class Startup public void ConfigureServices(IServiceCollection services)
{ {
public void ConfigureServices(IServiceCollection services) services.AddApplication<MyProjectNameHttpApiHostModule>();
{ }
services.AddApplication<MyProjectNameHttpApiHostModule>();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
{ {
app.InitializeApplication(); app.InitializeApplication();
}
} }
} }

11
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/Controllers/HomeController.cs

@ -1,13 +1,12 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc;
namespace MyCompanyName.MyProjectName.Controllers namespace MyCompanyName.MyProjectName.Controllers;
public class HomeController : AbpController
{ {
public class HomeController : AbpController public ActionResult Index()
{ {
public ActionResult Index() return Redirect("~/swagger");
{
return Redirect("~/swagger");
}
} }
} }

11
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyProjectNameBrandingProvider.cs

@ -1,11 +1,10 @@
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
using Volo.Abp.Ui.Branding; using Volo.Abp.Ui.Branding;
namespace MyCompanyName.MyProjectName namespace MyCompanyName.MyProjectName;
[Dependency(ReplaceServices = true)]
public class MyProjectNameBrandingProvider : DefaultBrandingProvider
{ {
[Dependency(ReplaceServices = true)] public override string AppName => "MyProjectName";
public class MyProjectNameBrandingProvider : DefaultBrandingProvider
{
public override string AppName => "MyProjectName";
}
} }

359
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyProjectNameHttpApiHostModule.cs

@ -29,219 +29,218 @@ using Volo.Abp.Swashbuckle;
using Volo.Abp.UI.Navigation.Urls; using Volo.Abp.UI.Navigation.Urls;
using Volo.Abp.VirtualFileSystem; using Volo.Abp.VirtualFileSystem;
namespace MyCompanyName.MyProjectName namespace MyCompanyName.MyProjectName;
[DependsOn(
typeof(MyProjectNameHttpApiModule),
typeof(AbpAutofacModule),
typeof(AbpAspNetCoreMultiTenancyModule),
typeof(MyProjectNameApplicationModule),
typeof(MyProjectNameEntityFrameworkCoreModule),
typeof(AbpAspNetCoreMvcUiBasicThemeModule),
typeof(AbpAspNetCoreAuthenticationJwtBearerModule),
typeof(AbpAccountWebIdentityServerModule),
typeof(AbpAspNetCoreSerilogModule),
typeof(AbpSwashbuckleModule)
)]
public class MyProjectNameHttpApiHostModule : AbpModule
{ {
[DependsOn( public override void ConfigureServices(ServiceConfigurationContext context)
typeof(MyProjectNameHttpApiModule),
typeof(AbpAutofacModule),
typeof(AbpAspNetCoreMultiTenancyModule),
typeof(MyProjectNameApplicationModule),
typeof(MyProjectNameEntityFrameworkCoreModule),
typeof(AbpAspNetCoreMvcUiBasicThemeModule),
typeof(AbpAspNetCoreAuthenticationJwtBearerModule),
typeof(AbpAccountWebIdentityServerModule),
typeof(AbpAspNetCoreSerilogModule),
typeof(AbpSwashbuckleModule)
)]
public class MyProjectNameHttpApiHostModule : AbpModule
{ {
public override void ConfigureServices(ServiceConfigurationContext context) var configuration = context.Services.GetConfiguration();
var hostingEnvironment = context.Services.GetHostingEnvironment();
ConfigureBundles();
ConfigureUrls(configuration);
ConfigureConventionalControllers();
ConfigureAuthentication(context, configuration);
ConfigureLocalization();
ConfigureVirtualFileSystem(context);
ConfigureCors(context, configuration);
ConfigureSwaggerServices(context, configuration);
}
private void ConfigureBundles()
{
Configure<AbpBundlingOptions>(options =>
{ {
var configuration = context.Services.GetConfiguration(); options.StyleBundles.Configure(
var hostingEnvironment = context.Services.GetHostingEnvironment(); BasicThemeBundles.Styles.Global,
bundle => { bundle.AddFiles("/global-styles.css"); }
ConfigureBundles(); );
ConfigureUrls(configuration); });
ConfigureConventionalControllers(); }
ConfigureAuthentication(context, configuration);
ConfigureLocalization();
ConfigureVirtualFileSystem(context);
ConfigureCors(context, configuration);
ConfigureSwaggerServices(context, configuration);
}
private void ConfigureBundles() private void ConfigureUrls(IConfiguration configuration)
{
Configure<AppUrlOptions>(options =>
{ {
Configure<AbpBundlingOptions>(options => options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"];
{ options.RedirectAllowedUrls.AddRange(configuration["App:RedirectAllowedUrls"].Split(','));
options.StyleBundles.Configure(
BasicThemeBundles.Styles.Global, options.Applications["Angular"].RootUrl = configuration["App:ClientUrl"];
bundle => { bundle.AddFiles("/global-styles.css"); } options.Applications["Angular"].Urls[AccountUrlNames.PasswordReset] = "account/reset-password";
); });
}); }
}
private void ConfigureUrls(IConfiguration configuration) private void ConfigureVirtualFileSystem(ServiceConfigurationContext context)
{
var hostingEnvironment = context.Services.GetHostingEnvironment();
if (hostingEnvironment.IsDevelopment())
{ {
Configure<AppUrlOptions>(options => Configure<AbpVirtualFileSystemOptions>(options =>
{ {
options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"]; options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameDomainSharedModule>(
options.RedirectAllowedUrls.AddRange(configuration["App:RedirectAllowedUrls"].Split(',')); Path.Combine(hostingEnvironment.ContentRootPath,
$"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain.Shared"));
options.Applications["Angular"].RootUrl = configuration["App:ClientUrl"]; options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameDomainModule>(
options.Applications["Angular"].Urls[AccountUrlNames.PasswordReset] = "account/reset-password"; Path.Combine(hostingEnvironment.ContentRootPath,
$"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain"));
options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameApplicationContractsModule>(
Path.Combine(hostingEnvironment.ContentRootPath,
$"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Application.Contracts"));
options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameApplicationModule>(
Path.Combine(hostingEnvironment.ContentRootPath,
$"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Application"));
}); });
} }
}
private void ConfigureVirtualFileSystem(ServiceConfigurationContext context) private void ConfigureConventionalControllers()
{
Configure<AbpAspNetCoreMvcOptions>(options =>
{ {
var hostingEnvironment = context.Services.GetHostingEnvironment(); options.ConventionalControllers.Create(typeof(MyProjectNameApplicationModule).Assembly);
});
}
if (hostingEnvironment.IsDevelopment()) private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration)
{
context.Services.AddAuthentication()
.AddJwtBearer(options =>
{ {
Configure<AbpVirtualFileSystemOptions>(options => options.Authority = configuration["AuthServer:Authority"];
options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]);
options.Audience = "MyProjectName";
options.BackchannelHttpHandler = new HttpClientHandler
{ {
options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameDomainSharedModule>( ServerCertificateCustomValidationCallback =
Path.Combine(hostingEnvironment.ContentRootPath, HttpClientHandler.DangerousAcceptAnyServerCertificateValidator
$"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain.Shared")); };
options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameDomainModule>( });
Path.Combine(hostingEnvironment.ContentRootPath, }
$"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain"));
options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameApplicationContractsModule>(
Path.Combine(hostingEnvironment.ContentRootPath,
$"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Application.Contracts"));
options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameApplicationModule>(
Path.Combine(hostingEnvironment.ContentRootPath,
$"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Application"));
});
}
}
private void ConfigureConventionalControllers() private static void ConfigureSwaggerServices(ServiceConfigurationContext context, IConfiguration configuration)
{ {
Configure<AbpAspNetCoreMvcOptions>(options => context.Services.AddAbpSwaggerGenWithOAuth(
configuration["AuthServer:Authority"],
new Dictionary<string, string>
{ {
options.ConventionalControllers.Create(typeof(MyProjectNameApplicationModule).Assembly); {"MyProjectName", "MyProjectName API"}
},
options =>
{
options.SwaggerDoc("v1", new OpenApiInfo { Title = "MyProjectName API", Version = "v1" });
options.DocInclusionPredicate((docName, description) => true);
options.CustomSchemaIds(type => type.FullName);
}); });
} }
private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration)
{
context.Services.AddAuthentication()
.AddJwtBearer(options =>
{
options.Authority = configuration["AuthServer:Authority"];
options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]);
options.Audience = "MyProjectName";
options.BackchannelHttpHandler = new HttpClientHandler
{
ServerCertificateCustomValidationCallback =
HttpClientHandler.DangerousAcceptAnyServerCertificateValidator
};
});
}
private static void ConfigureSwaggerServices(ServiceConfigurationContext context, IConfiguration configuration) private void ConfigureLocalization()
{
Configure<AbpLocalizationOptions>(options =>
{ {
context.Services.AddAbpSwaggerGenWithOAuth( options.Languages.Add(new LanguageInfo("ar", "ar", "العربية"));
configuration["AuthServer:Authority"], options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština"));
new Dictionary<string, string> options.Languages.Add(new LanguageInfo("en", "en", "English"));
{ options.Languages.Add(new LanguageInfo("en-GB", "en-GB", "English (UK)"));
{"MyProjectName", "MyProjectName API"} options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish"));
}, options.Languages.Add(new LanguageInfo("fr", "fr", "Français"));
options => options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in"));
{ options.Languages.Add(new LanguageInfo("is", "is", "Icelandic", "is"));
options.SwaggerDoc("v1", new OpenApiInfo {Title = "MyProjectName API", Version = "v1"}); options.Languages.Add(new LanguageInfo("it", "it", "Italiano", "it"));
options.DocInclusionPredicate((docName, description) => true); options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar"));
options.CustomSchemaIds(type => type.FullName); options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português"));
}); options.Languages.Add(new LanguageInfo("ro-RO", "ro-RO", "Română"));
} options.Languages.Add(new LanguageInfo("ru", "ru", "Русский"));
options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak"));
options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe"));
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文"));
options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文"));
options.Languages.Add(new LanguageInfo("de-DE", "de-DE", "Deutsch", "de"));
options.Languages.Add(new LanguageInfo("es", "es", "Español", "es"));
});
}
private void ConfigureLocalization() private void ConfigureCors(ServiceConfigurationContext context, IConfiguration configuration)
{
context.Services.AddCors(options =>
{ {
Configure<AbpLocalizationOptions>(options => options.AddDefaultPolicy(builder =>
{ {
options.Languages.Add(new LanguageInfo("ar", "ar", "العربية")); builder
options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština")); .WithOrigins(
options.Languages.Add(new LanguageInfo("en", "en", "English")); configuration["App:CorsOrigins"]
options.Languages.Add(new LanguageInfo("en-GB", "en-GB", "English (UK)")); .Split(",", StringSplitOptions.RemoveEmptyEntries)
options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish")); .Select(o => o.RemovePostFix("/"))
options.Languages.Add(new LanguageInfo("fr", "fr", "Français")); .ToArray()
options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in")); )
options.Languages.Add(new LanguageInfo("is", "is", "Icelandic", "is")); .WithAbpExposedHeaders()
options.Languages.Add(new LanguageInfo("it", "it", "Italiano", "it")); .SetIsOriginAllowedToAllowWildcardSubdomains()
options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar")); .AllowAnyHeader()
options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português")); .AllowAnyMethod()
options.Languages.Add(new LanguageInfo("ro-RO", "ro-RO", "Română")); .AllowCredentials();
options.Languages.Add(new LanguageInfo("ru", "ru", "Русский"));
options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak"));
options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe"));
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文"));
options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文"));
options.Languages.Add(new LanguageInfo("de-DE", "de-DE", "Deutsch", "de"));
options.Languages.Add(new LanguageInfo("es", "es", "Español", "es"));
}); });
} });
}
private void ConfigureCors(ServiceConfigurationContext context, IConfiguration configuration) public override void OnApplicationInitialization(ApplicationInitializationContext context)
{ {
context.Services.AddCors(options => var app = context.GetApplicationBuilder();
{ var env = context.GetEnvironment();
options.AddDefaultPolicy( builder =>
{
builder
.WithOrigins(
configuration["App:CorsOrigins"]
.Split(",", StringSplitOptions.RemoveEmptyEntries)
.Select(o => o.RemovePostFix("/"))
.ToArray()
)
.WithAbpExposedHeaders()
.SetIsOriginAllowedToAllowWildcardSubdomains()
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
});
}
public override void OnApplicationInitialization(ApplicationInitializationContext context) if (env.IsDevelopment())
{ {
var app = context.GetApplicationBuilder(); app.UseDeveloperExceptionPage();
var env = context.GetEnvironment(); }
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseAbpRequestLocalization(); app.UseAbpRequestLocalization();
if (!env.IsDevelopment()) if (!env.IsDevelopment())
{ {
app.UseErrorPage(); app.UseErrorPage();
} }
app.UseCorrelationId(); app.UseCorrelationId();
app.UseStaticFiles(); app.UseStaticFiles();
app.UseRouting(); app.UseRouting();
app.UseCors(); app.UseCors();
app.UseAuthentication(); app.UseAuthentication();
app.UseJwtTokenMiddleware(); app.UseJwtTokenMiddleware();
if (MultiTenancyConsts.IsEnabled) if (MultiTenancyConsts.IsEnabled)
{ {
app.UseMultiTenancy(); app.UseMultiTenancy();
} }
app.UseUnitOfWork(); app.UseUnitOfWork();
app.UseIdentityServer(); app.UseIdentityServer();
app.UseAuthorization(); app.UseAuthorization();
app.UseSwagger(); app.UseSwagger();
app.UseAbpSwaggerUI(c => app.UseAbpSwaggerUI(c =>
{ {
c.SwaggerEndpoint("/swagger/v1/swagger.json", "MyProjectName API"); c.SwaggerEndpoint("/swagger/v1/swagger.json", "MyProjectName API");
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>(); var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
c.OAuthClientId(configuration["AuthServer:SwaggerClientId"]); c.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
c.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]); c.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);
c.OAuthScopes("MyProjectName"); c.OAuthScopes("MyProjectName");
}); });
app.UseAuditing(); app.UseAuditing();
app.UseAbpSerilogEnrichers(); app.UseAbpSerilogEnrichers();
app.UseConfiguredEndpoints(); app.UseConfiguredEndpoints();
}
} }
} }

65
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/Program.cs

@ -5,52 +5,51 @@ using Microsoft.Extensions.Hosting;
using Serilog; using Serilog;
using Serilog.Events; using Serilog.Events;
namespace MyCompanyName.MyProjectName namespace MyCompanyName.MyProjectName;
public class Program
{ {
public class Program public static int Main(string[] args)
{ {
public static int Main(string[] args) Log.Logger = new LoggerConfiguration()
{
Log.Logger = new LoggerConfiguration()
#if DEBUG #if DEBUG
.MinimumLevel.Debug() .MinimumLevel.Debug()
#else #else
.MinimumLevel.Information() .MinimumLevel.Information()
#endif #endif
.MinimumLevel.Override("Microsoft", LogEventLevel.Information) .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) .MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
.Enrich.FromLogContext() .Enrich.FromLogContext()
.WriteTo.Async(c => c.File("Logs/logs.txt")) .WriteTo.Async(c => c.File("Logs/logs.txt"))
#if DEBUG #if DEBUG
.WriteTo.Async(c => c.Console()) .WriteTo.Async(c => c.Console())
#endif #endif
.CreateLogger(); .CreateLogger();
try try
{ {
Log.Information("Starting MyCompanyName.MyProjectName.HttpApi.Host."); Log.Information("Starting MyCompanyName.MyProjectName.HttpApi.Host.");
CreateHostBuilder(args).Build().Run(); CreateHostBuilder(args).Build().Run();
return 0; return 0;
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Fatal(ex, "Host terminated unexpectedly!"); Log.Fatal(ex, "Host terminated unexpectedly!");
return 1; return 1;
} }
finally finally
{ {
Log.CloseAndFlush(); Log.CloseAndFlush();
}
} }
internal static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.AddAppSettingsSecretsJson()
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.UseAutofac()
.UseSerilog();
} }
internal static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.AddAppSettingsSecretsJson()
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.UseAutofac()
.UseSerilog();
} }

19
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/Startup.cs

@ -3,18 +3,17 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace MyCompanyName.MyProjectName namespace MyCompanyName.MyProjectName;
public class Startup
{ {
public class Startup public void ConfigureServices(IServiceCollection services)
{ {
public void ConfigureServices(IServiceCollection services) services.AddApplication<MyProjectNameHttpApiHostModule>();
{ }
services.AddApplication<MyProjectNameHttpApiHostModule>();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
{ {
app.InitializeApplication(); app.InitializeApplication();
}
} }
} }

17
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi/Controllers/MyProjectNameController.cs

@ -1,15 +1,14 @@
using MyCompanyName.MyProjectName.Localization; using MyCompanyName.MyProjectName.Localization;
using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc;
namespace MyCompanyName.MyProjectName.Controllers namespace MyCompanyName.MyProjectName.Controllers;
/* Inherit your controllers from this class.
*/
public abstract class MyProjectNameController : AbpControllerBase
{ {
/* Inherit your controllers from this class. protected MyProjectNameController()
*/
public abstract class MyProjectNameController : AbpControllerBase
{ {
protected MyProjectNameController() LocalizationResource = typeof(MyProjectNameResource);
{
LocalizationResource = typeof(MyProjectNameResource);
}
} }
} }

13
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi/Models/Test/TestModel.cs

@ -1,11 +1,10 @@
using System; using System;
namespace MyCompanyName.MyProjectName.Models.Test namespace MyCompanyName.MyProjectName.Models.Test;
public class TestModel
{ {
public class TestModel public string Name { get; set; }
{
public string Name { get; set; }
public DateTime BirthDate { get; set; } public DateTime BirthDate { get; set; }
} }
}

49
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi/MyProjectNameHttpApiModule.cs

@ -9,34 +9,33 @@ using Volo.Abp.PermissionManagement.HttpApi;
using Volo.Abp.SettingManagement; using Volo.Abp.SettingManagement;
using Volo.Abp.TenantManagement; using Volo.Abp.TenantManagement;
namespace MyCompanyName.MyProjectName namespace MyCompanyName.MyProjectName;
[DependsOn(
typeof(MyProjectNameApplicationContractsModule),
typeof(AbpAccountHttpApiModule),
typeof(AbpIdentityHttpApiModule),
typeof(AbpPermissionManagementHttpApiModule),
typeof(AbpTenantManagementHttpApiModule),
typeof(AbpFeatureManagementHttpApiModule),
typeof(AbpSettingManagementHttpApiModule)
)]
public class MyProjectNameHttpApiModule : AbpModule
{ {
[DependsOn( public override void ConfigureServices(ServiceConfigurationContext context)
typeof(MyProjectNameApplicationContractsModule),
typeof(AbpAccountHttpApiModule),
typeof(AbpIdentityHttpApiModule),
typeof(AbpPermissionManagementHttpApiModule),
typeof(AbpTenantManagementHttpApiModule),
typeof(AbpFeatureManagementHttpApiModule),
typeof(AbpSettingManagementHttpApiModule)
)]
public class MyProjectNameHttpApiModule : AbpModule
{ {
public override void ConfigureServices(ServiceConfigurationContext context) ConfigureLocalization();
{ }
ConfigureLocalization();
}
private void ConfigureLocalization() private void ConfigureLocalization()
{
Configure<AbpLocalizationOptions>(options =>
{ {
Configure<AbpLocalizationOptions>(options => options.Resources
{ .Get<MyProjectNameResource>()
options.Resources .AddBaseTypes(
.Get<MyProjectNameResource>() typeof(AbpUiResource)
.AddBaseTypes( );
typeof(AbpUiResource) });
);
});
}
} }
} }

11
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameBrandingProvider.cs

@ -1,11 +1,10 @@
using Volo.Abp.Ui.Branding; using Volo.Abp.Ui.Branding;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
namespace MyCompanyName.MyProjectName namespace MyCompanyName.MyProjectName;
[Dependency(ReplaceServices = true)]
public class MyProjectNameBrandingProvider : DefaultBrandingProvider
{ {
[Dependency(ReplaceServices = true)] public override string AppName => "MyProjectName";
public class MyProjectNameBrandingProvider : DefaultBrandingProvider
{
public override string AppName => "MyProjectName";
}
} }

271
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs

@ -32,169 +32,168 @@ using Volo.Abp.UI.Navigation.Urls;
using Volo.Abp.UI; using Volo.Abp.UI;
using Volo.Abp.VirtualFileSystem; using Volo.Abp.VirtualFileSystem;
namespace MyCompanyName.MyProjectName namespace MyCompanyName.MyProjectName;
[DependsOn(
typeof(AbpAutofacModule),
typeof(AbpCachingStackExchangeRedisModule),
typeof(AbpAccountWebIdentityServerModule),
typeof(AbpAccountApplicationModule),
typeof(AbpAccountHttpApiModule),
typeof(AbpAspNetCoreMvcUiBasicThemeModule),
typeof(MyProjectNameEntityFrameworkCoreModule),
typeof(AbpAspNetCoreSerilogModule)
)]
public class MyProjectNameIdentityServerModule : AbpModule
{ {
[DependsOn( public override void ConfigureServices(ServiceConfigurationContext context)
typeof(AbpAutofacModule),
typeof(AbpCachingStackExchangeRedisModule),
typeof(AbpAccountWebIdentityServerModule),
typeof(AbpAccountApplicationModule),
typeof(AbpAccountHttpApiModule),
typeof(AbpAspNetCoreMvcUiBasicThemeModule),
typeof(MyProjectNameEntityFrameworkCoreModule),
typeof(AbpAspNetCoreSerilogModule)
)]
public class MyProjectNameIdentityServerModule : AbpModule
{ {
public override void ConfigureServices(ServiceConfigurationContext context) var hostingEnvironment = context.Services.GetHostingEnvironment();
{ var configuration = context.Services.GetConfiguration();
var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.GetConfiguration();
Configure<AbpLocalizationOptions>(options =>
{
options.Resources
.Get<MyProjectNameResource>()
.AddBaseTypes(
typeof(AbpUiResource)
);
options.Languages.Add(new LanguageInfo("ar", "ar", "العربية"));
options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština"));
options.Languages.Add(new LanguageInfo("en", "en", "English"));
options.Languages.Add(new LanguageInfo("en-GB", "en-GB", "English (UK)"));
options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish"));
options.Languages.Add(new LanguageInfo("fr", "fr", "Français"));
options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in"));
options.Languages.Add(new LanguageInfo("is", "is", "Icelandic", "is"));
options.Languages.Add(new LanguageInfo("it", "it", "Italiano", "it"));
options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar"));
options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português"));
options.Languages.Add(new LanguageInfo("ro-RO", "ro-RO", "Română"));
options.Languages.Add(new LanguageInfo("ru", "ru", "Русский"));
options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak"));
options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe"));
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文"));
options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文"));
options.Languages.Add(new LanguageInfo("de-DE", "de-DE", "Deutsch", "de"));
options.Languages.Add(new LanguageInfo("es", "es", "Español", "es"));
});
Configure<AbpBundlingOptions>(options => Configure<AbpLocalizationOptions>(options =>
{ {
options.StyleBundles.Configure( options.Resources
BasicThemeBundles.Styles.Global, .Get<MyProjectNameResource>()
bundle => .AddBaseTypes(
{ typeof(AbpUiResource)
bundle.AddFiles("/global-styles.css");
}
); );
});
Configure<AbpAuditingOptions>(options => options.Languages.Add(new LanguageInfo("ar", "ar", "العربية"));
{ options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština"));
options.Languages.Add(new LanguageInfo("en", "en", "English"));
options.Languages.Add(new LanguageInfo("en-GB", "en-GB", "English (UK)"));
options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish"));
options.Languages.Add(new LanguageInfo("fr", "fr", "Français"));
options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in"));
options.Languages.Add(new LanguageInfo("is", "is", "Icelandic", "is"));
options.Languages.Add(new LanguageInfo("it", "it", "Italiano", "it"));
options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar"));
options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português"));
options.Languages.Add(new LanguageInfo("ro-RO", "ro-RO", "Română"));
options.Languages.Add(new LanguageInfo("ru", "ru", "Русский"));
options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak"));
options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe"));
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文"));
options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文"));
options.Languages.Add(new LanguageInfo("de-DE", "de-DE", "Deutsch", "de"));
options.Languages.Add(new LanguageInfo("es", "es", "Español", "es"));
});
Configure<AbpBundlingOptions>(options =>
{
options.StyleBundles.Configure(
BasicThemeBundles.Styles.Global,
bundle =>
{
bundle.AddFiles("/global-styles.css");
}
);
});
Configure<AbpAuditingOptions>(options =>
{
//options.IsEnabledForGetRequests = true; //options.IsEnabledForGetRequests = true;
options.ApplicationName = "AuthServer"; options.ApplicationName = "AuthServer";
}); });
if (hostingEnvironment.IsDevelopment()) if (hostingEnvironment.IsDevelopment())
{
Configure<AbpVirtualFileSystemOptions>(options =>
{ {
Configure<AbpVirtualFileSystemOptions>(options =>
{
//<TEMPLATE-REMOVE> //<TEMPLATE-REMOVE>
options.FileSets.ReplaceEmbeddedByPhysical<AbpUiModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.UI", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical<AbpUiModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.UI", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiBootstrapModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Bootstrap", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiBootstrapModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Bootstrap", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiThemeSharedModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiThemeSharedModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiBasicThemeModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}basic-theme{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiBasicThemeModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}basic-theme{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpAccountWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}account{0}src{0}Volo.Abp.Account.Web", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical<AbpAccountWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}account{0}src{0}Volo.Abp.Account.Web", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpAccountWebIdentityServerModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}account{0}src{0}Volo.Abp.Account.Web.IdentityServer", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical<AbpAccountWebIdentityServerModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}account{0}src{0}Volo.Abp.Account.Web.IdentityServer", Path.DirectorySeparatorChar)));
//</TEMPLATE-REMOVE> //</TEMPLATE-REMOVE>
options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameDomainSharedModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain.Shared")); options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameDomainSharedModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain.Shared"));
options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameDomainModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain")); options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameDomainModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain"));
}); });
} }
Configure<AppUrlOptions>(options => Configure<AppUrlOptions>(options =>
{ {
options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"]; options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"];
options.RedirectAllowedUrls.AddRange(configuration["App:RedirectAllowedUrls"].Split(',')); options.RedirectAllowedUrls.AddRange(configuration["App:RedirectAllowedUrls"].Split(','));
options.Applications["Angular"].RootUrl = configuration["App:ClientUrl"]; options.Applications["Angular"].RootUrl = configuration["App:ClientUrl"];
options.Applications["Angular"].Urls[AccountUrlNames.PasswordReset] = "account/reset-password"; options.Applications["Angular"].Urls[AccountUrlNames.PasswordReset] = "account/reset-password";
}); });
Configure<AbpBackgroundJobOptions>(options => Configure<AbpBackgroundJobOptions>(options =>
{ {
options.IsJobExecutionEnabled = false; options.IsJobExecutionEnabled = false;
}); });
Configure<AbpDistributedCacheOptions>(options => Configure<AbpDistributedCacheOptions>(options =>
{ {
options.KeyPrefix = "MyProjectName:"; options.KeyPrefix = "MyProjectName:";
}); });
var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("MyProjectName"); var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("MyProjectName");
if (!hostingEnvironment.IsDevelopment()) if (!hostingEnvironment.IsDevelopment())
{ {
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]);
dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys"); dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys");
} }
context.Services.AddCors(options => context.Services.AddCors(options =>
{
options.AddDefaultPolicy(builder =>
{ {
options.AddDefaultPolicy(builder => builder
{ .WithOrigins(
builder configuration["App:CorsOrigins"]
.WithOrigins( .Split(",", StringSplitOptions.RemoveEmptyEntries)
configuration["App:CorsOrigins"] .Select(o => o.RemovePostFix("/"))
.Split(",", StringSplitOptions.RemoveEmptyEntries) .ToArray()
.Select(o => o.RemovePostFix("/")) )
.ToArray() .WithAbpExposedHeaders()
) .SetIsOriginAllowedToAllowWildcardSubdomains()
.WithAbpExposedHeaders() .AllowAnyHeader()
.SetIsOriginAllowedToAllowWildcardSubdomains() .AllowAnyMethod()
.AllowAnyHeader() .AllowCredentials();
.AllowAnyMethod()
.AllowCredentials();
});
}); });
} });
}
public override void OnApplicationInitialization(ApplicationInitializationContext context) public override void OnApplicationInitialization(ApplicationInitializationContext context)
{ {
var app = context.GetApplicationBuilder(); var app = context.GetApplicationBuilder();
var env = context.GetEnvironment(); var env = context.GetEnvironment();
if (env.IsDevelopment()) if (env.IsDevelopment())
{ {
app.UseDeveloperExceptionPage(); app.UseDeveloperExceptionPage();
} }
app.UseAbpRequestLocalization(); app.UseAbpRequestLocalization();
if (!env.IsDevelopment()) if (!env.IsDevelopment())
{ {
app.UseErrorPage(); app.UseErrorPage();
} }
app.UseCorrelationId(); app.UseCorrelationId();
app.UseStaticFiles(); app.UseStaticFiles();
app.UseRouting(); app.UseRouting();
app.UseCors(); app.UseCors();
app.UseAuthentication(); app.UseAuthentication();
if (MultiTenancyConsts.IsEnabled) if (MultiTenancyConsts.IsEnabled)
{ {
app.UseMultiTenancy(); app.UseMultiTenancy();
}
app.UseUnitOfWork();
app.UseIdentityServer();
app.UseAuthorization();
app.UseAuditing();
app.UseAbpSerilogEnrichers();
app.UseConfiguredEndpoints();
} }
app.UseUnitOfWork();
app.UseIdentityServer();
app.UseAuthorization();
app.UseAuditing();
app.UseAbpSerilogEnrichers();
app.UseConfiguredEndpoints();
} }
} }

11
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/Pages/Index.cshtml.cs

@ -1,11 +1,10 @@
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; using Volo.Abp.AspNetCore.Mvc.UI.RazorPages;
namespace MyCompanyName.MyProjectName.Pages namespace MyCompanyName.MyProjectName.Pages;
public class IndexModel : AbpPageModel
{ {
public class IndexModel : AbpPageModel public void OnGet()
{ {
public void OnGet()
{
}
} }
} }

65
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/Program.cs

@ -5,52 +5,51 @@ using Microsoft.Extensions.Hosting;
using Serilog; using Serilog;
using Serilog.Events; using Serilog.Events;
namespace MyCompanyName.MyProjectName namespace MyCompanyName.MyProjectName;
public class Program
{ {
public class Program public static int Main(string[] args)
{ {
public static int Main(string[] args) Log.Logger = new LoggerConfiguration()
{
Log.Logger = new LoggerConfiguration()
#if DEBUG #if DEBUG
.MinimumLevel.Debug() .MinimumLevel.Debug()
#else #else
.MinimumLevel.Information() .MinimumLevel.Information()
#endif #endif
.MinimumLevel.Override("Microsoft", LogEventLevel.Information) .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) .MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
.Enrich.FromLogContext() .Enrich.FromLogContext()
.WriteTo.Async(c => c.File("Logs/logs.txt")) .WriteTo.Async(c => c.File("Logs/logs.txt"))
#if DEBUG #if DEBUG
.WriteTo.Async(c => c.Console()) .WriteTo.Async(c => c.Console())
#endif #endif
.CreateLogger(); .CreateLogger();
try try
{ {
Log.Information("Starting MyCompanyName.MyProjectName.IdentityServer."); Log.Information("Starting MyCompanyName.MyProjectName.IdentityServer.");
CreateHostBuilder(args).Build().Run(); CreateHostBuilder(args).Build().Run();
return 0; return 0;
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Fatal(ex, "MyCompanyName.MyProjectName.IdentityServer terminated unexpectedly!"); Log.Fatal(ex, "MyCompanyName.MyProjectName.IdentityServer terminated unexpectedly!");
return 1; return 1;
} }
finally finally
{ {
Log.CloseAndFlush(); Log.CloseAndFlush();
}
} }
internal static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.AddAppSettingsSecretsJson()
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.UseAutofac()
.UseSerilog();
} }
internal static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.AddAppSettingsSecretsJson()
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.UseAutofac()
.UseSerilog();
} }

19
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/Startup.cs

@ -1,18 +1,17 @@
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
namespace MyCompanyName.MyProjectName namespace MyCompanyName.MyProjectName;
public class Startup
{ {
public class Startup public void ConfigureServices(IServiceCollection services)
{ {
public void ConfigureServices(IServiceCollection services) services.AddApplication<MyProjectNameIdentityServerModule>();
{ }
services.AddApplication<MyProjectNameIdentityServerModule>();
}
public void Configure(IApplicationBuilder app) public void Configure(IApplicationBuilder app)
{ {
app.InitializeApplication(); app.InitializeApplication();
}
} }
} }

47
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDb/MongoDbMyProjectNameDbSchemaMigrator.cs

@ -7,38 +7,37 @@ using Volo.Abp.Data;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
using Volo.Abp.MongoDB; using Volo.Abp.MongoDB;
namespace MyCompanyName.MyProjectName.MongoDB namespace MyCompanyName.MyProjectName.MongoDB;
public class MongoDbMyProjectNameDbSchemaMigrator : IMyProjectNameDbSchemaMigrator, ITransientDependency
{ {
public class MongoDbMyProjectNameDbSchemaMigrator : IMyProjectNameDbSchemaMigrator , ITransientDependency private readonly IServiceProvider _serviceProvider;
public MongoDbMyProjectNameDbSchemaMigrator(IServiceProvider serviceProvider)
{ {
private readonly IServiceProvider _serviceProvider; _serviceProvider = serviceProvider;
}
public MongoDbMyProjectNameDbSchemaMigrator(IServiceProvider serviceProvider) public async Task MigrateAsync()
{ {
_serviceProvider = serviceProvider; var dbContexts = _serviceProvider.GetServices<IAbpMongoDbContext>();
} var connectionStringResolver = _serviceProvider.GetRequiredService<IConnectionStringResolver>();
public async Task MigrateAsync() foreach (var dbContext in dbContexts)
{ {
var dbContexts = _serviceProvider.GetServices<IAbpMongoDbContext>(); var connectionString =
var connectionStringResolver = _serviceProvider.GetRequiredService<IConnectionStringResolver>(); await connectionStringResolver.ResolveAsync(
ConnectionStringNameAttribute.GetConnStringName(dbContext.GetType()));
var mongoUrl = new MongoUrl(connectionString);
var databaseName = mongoUrl.DatabaseName;
var client = new MongoClient(mongoUrl);
foreach (var dbContext in dbContexts) if (databaseName.IsNullOrWhiteSpace())
{ {
var connectionString = databaseName = ConnectionStringNameAttribute.GetConnStringName(dbContext.GetType());
await connectionStringResolver.ResolveAsync(
ConnectionStringNameAttribute.GetConnStringName(dbContext.GetType()));
var mongoUrl = new MongoUrl(connectionString);
var databaseName = mongoUrl.DatabaseName;
var client = new MongoClient(mongoUrl);
if (databaseName.IsNullOrWhiteSpace())
{
databaseName = ConnectionStringNameAttribute.GetConnStringName(dbContext.GetType());
}
(dbContext as AbpMongoDbContext)?.InitializeCollections(client.GetDatabase(databaseName));
} }
(dbContext as AbpMongoDbContext)?.InitializeCollections(client.GetDatabase(databaseName));
} }
} }
} }

29
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDb/MyProjectNameMongoDbContext.cs

@ -1,23 +1,22 @@
using Volo.Abp.Data; using Volo.Abp.Data;
using Volo.Abp.MongoDB; using Volo.Abp.MongoDB;
namespace MyCompanyName.MyProjectName.MongoDB namespace MyCompanyName.MyProjectName.MongoDB;
[ConnectionStringName("Default")]
public class MyProjectNameMongoDbContext : AbpMongoDbContext
{ {
[ConnectionStringName("Default")] /* Add mongo collections here. Example:
public class MyProjectNameMongoDbContext : AbpMongoDbContext * public IMongoCollection<Question> Questions => Collection<Question>();
{ */
/* Add mongo collections here. Example:
* public IMongoCollection<Question> Questions => Collection<Question>();
*/
protected override void CreateModel(IMongoModelBuilder modelBuilder) protected override void CreateModel(IMongoModelBuilder modelBuilder)
{ {
base.CreateModel(modelBuilder); base.CreateModel(modelBuilder);
//builder.Entity<YourEntity>(b => //builder.Entity<YourEntity>(b =>
//{ //{
// //... // //...
//}); //});
}
} }
} }

45
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDb/MyProjectNameMongoDbModule.cs

@ -10,32 +10,31 @@ using Volo.Abp.SettingManagement.MongoDB;
using Volo.Abp.TenantManagement.MongoDB; using Volo.Abp.TenantManagement.MongoDB;
using Volo.Abp.Uow; using Volo.Abp.Uow;
namespace MyCompanyName.MyProjectName.MongoDB namespace MyCompanyName.MyProjectName.MongoDB;
[DependsOn(
typeof(MyProjectNameDomainModule),
typeof(AbpPermissionManagementMongoDbModule),
typeof(AbpSettingManagementMongoDbModule),
typeof(AbpIdentityMongoDbModule),
typeof(AbpIdentityServerMongoDbModule),
typeof(AbpBackgroundJobsMongoDbModule),
typeof(AbpAuditLoggingMongoDbModule),
typeof(AbpTenantManagementMongoDbModule),
typeof(AbpFeatureManagementMongoDbModule)
)]
public class MyProjectNameMongoDbModule : AbpModule
{ {
[DependsOn( public override void ConfigureServices(ServiceConfigurationContext context)
typeof(MyProjectNameDomainModule),
typeof(AbpPermissionManagementMongoDbModule),
typeof(AbpSettingManagementMongoDbModule),
typeof(AbpIdentityMongoDbModule),
typeof(AbpIdentityServerMongoDbModule),
typeof(AbpBackgroundJobsMongoDbModule),
typeof(AbpAuditLoggingMongoDbModule),
typeof(AbpTenantManagementMongoDbModule),
typeof(AbpFeatureManagementMongoDbModule)
)]
public class MyProjectNameMongoDbModule : AbpModule
{ {
public override void ConfigureServices(ServiceConfigurationContext context) context.Services.AddMongoDbContext<MyProjectNameMongoDbContext>(options =>
{ {
context.Services.AddMongoDbContext<MyProjectNameMongoDbContext>(options => options.AddDefaultRepositories();
{ });
options.AddDefaultRepositories();
});
Configure<AbpUnitOfWorkDefaultOptions>(options => Configure<AbpUnitOfWorkDefaultOptions>(options =>
{ {
options.TransactionBehavior = UnitOfWorkTransactionBehavior.Disabled; options.TransactionBehavior = UnitOfWorkTransactionBehavior.Disabled;
}); });
}
} }
} }

11
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Components/Toolbar/LoginLink/LoginLinkViewComponent.cs

@ -1,13 +1,12 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc;
namespace MyCompanyName.MyProjectName.Web.Components.Toolbar.LoginLink namespace MyCompanyName.MyProjectName.Web.Components.Toolbar.LoginLink;
public class LoginLinkViewComponent : AbpViewComponent
{ {
public class LoginLinkViewComponent : AbpViewComponent public virtual IViewComponentResult Invoke()
{ {
public virtual IViewComponentResult Invoke() return View("~/Components/Toolbar/LoginLink/Default.cshtml");
{
return View("~/Components/Toolbar/LoginLink/Default.cshtml");
}
} }
} }

9
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Controllers/AccountController.cs

@ -1,9 +1,8 @@
using Volo.Abp.AspNetCore.Mvc.Authentication; using Volo.Abp.AspNetCore.Mvc.Authentication;
namespace MyCompanyName.MyProjectName.Web.Controllers namespace MyCompanyName.MyProjectName.Web.Controllers;
public class AccountController : ChallengeAccountController
{ {
public class AccountController : ChallengeAccountController
{
} }
}

103
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Menus/MyProjectNameMenuContributor.cs

@ -12,71 +12,70 @@ using Volo.Abp.TenantManagement.Web.Navigation;
using Volo.Abp.UI.Navigation; using Volo.Abp.UI.Navigation;
using Volo.Abp.Users; using Volo.Abp.Users;
namespace MyCompanyName.MyProjectName.Web.Menus namespace MyCompanyName.MyProjectName.Web.Menus;
public class MyProjectNameMenuContributor : IMenuContributor
{ {
public class MyProjectNameMenuContributor : IMenuContributor private readonly IConfiguration _configuration;
public MyProjectNameMenuContributor(IConfiguration configuration)
{ {
private readonly IConfiguration _configuration; _configuration = configuration;
}
public MyProjectNameMenuContributor(IConfiguration configuration) public async Task ConfigureMenuAsync(MenuConfigurationContext context)
{
if (context.Menu.Name == StandardMenus.Main)
{ {
_configuration = configuration; await ConfigureMainMenuAsync(context);
} }
else if (context.Menu.Name == StandardMenus.User)
public async Task ConfigureMenuAsync(MenuConfigurationContext context)
{ {
if (context.Menu.Name == StandardMenus.Main) await ConfigureUserMenuAsync(context);
{
await ConfigureMainMenuAsync(context);
}
else if (context.Menu.Name == StandardMenus.User)
{
await ConfigureUserMenuAsync(context);
}
} }
}
private Task ConfigureMainMenuAsync(MenuConfigurationContext context) private Task ConfigureMainMenuAsync(MenuConfigurationContext context)
{ {
var administration = context.Menu.GetAdministration(); var administration = context.Menu.GetAdministration();
var l = context.GetLocalizer<MyProjectNameResource>(); var l = context.GetLocalizer<MyProjectNameResource>();
context.Menu.Items.Insert( context.Menu.Items.Insert(
0, 0,
new ApplicationMenuItem( new ApplicationMenuItem(
MyProjectNameMenus.Home, MyProjectNameMenus.Home,
l["Menu:Home"], l["Menu:Home"],
"~/", "~/",
icon: "fas fa-home", icon: "fas fa-home",
order: 0 order: 0
) )
); );
if (MultiTenancyConsts.IsEnabled)
{
administration.SetSubItemOrder(TenantManagementMenuNames.GroupName, 1);
}
else
{
administration.TryRemoveMenuItem(TenantManagementMenuNames.GroupName);
}
administration.SetSubItemOrder(IdentityMenuNames.GroupName, 2);
administration.SetSubItemOrder(SettingManagementMenuNames.GroupName, 3);
return Task.CompletedTask; if (MultiTenancyConsts.IsEnabled)
{
administration.SetSubItemOrder(TenantManagementMenuNames.GroupName, 1);
} }
else
private Task ConfigureUserMenuAsync(MenuConfigurationContext context)
{ {
var l = context.GetLocalizer<MyProjectNameResource>(); administration.TryRemoveMenuItem(TenantManagementMenuNames.GroupName);
var accountStringLocalizer = context.GetLocalizer<AccountResource>(); }
var identityServerUrl = _configuration["AuthServer:Authority"] ?? "";
context.Menu.AddItem(new ApplicationMenuItem("Account.Manage", accountStringLocalizer["MyAccount"], administration.SetSubItemOrder(IdentityMenuNames.GroupName, 2);
$"{identityServerUrl.EnsureEndsWith('/')}Account/Manage?returnUrl={_configuration["App:SelfUrl"]}", icon: "fa fa-cog", order: 1000, null, "_blank").RequireAuthenticated()); administration.SetSubItemOrder(SettingManagementMenuNames.GroupName, 3);
context.Menu.AddItem(new ApplicationMenuItem("Account.Logout", l["Logout"], url: "~/Account/Logout", icon: "fa fa-power-off", order: int.MaxValue - 1000).RequireAuthenticated());
return Task.CompletedTask; return Task.CompletedTask;
} }
private Task ConfigureUserMenuAsync(MenuConfigurationContext context)
{
var l = context.GetLocalizer<MyProjectNameResource>();
var accountStringLocalizer = context.GetLocalizer<AccountResource>();
var identityServerUrl = _configuration["AuthServer:Authority"] ?? "";
context.Menu.AddItem(new ApplicationMenuItem("Account.Manage", accountStringLocalizer["MyAccount"],
$"{identityServerUrl.EnsureEndsWith('/')}Account/Manage?returnUrl={_configuration["App:SelfUrl"]}", icon: "fa fa-cog", order: 1000, null, "_blank").RequireAuthenticated());
context.Menu.AddItem(new ApplicationMenuItem("Account.Logout", l["Logout"], url: "~/Account/Logout", icon: "fa fa-power-off", order: int.MaxValue - 1000).RequireAuthenticated());
return Task.CompletedTask;
} }
} }

15
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Menus/MyProjectNameMenus.cs

@ -1,11 +1,10 @@
namespace MyCompanyName.MyProjectName.Web.Menus namespace MyCompanyName.MyProjectName.Web.Menus;
public class MyProjectNameMenus
{ {
public class MyProjectNameMenus private const string Prefix = "MyProjectName";
{ public const string Home = Prefix + ".Home";
private const string Prefix = "MyProjectName";
public const string Home = Prefix + ".Home";
//Add your menu items here... //Add your menu items here...
} }
}

25
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Menus/MyProjectNameToolbarContributor.cs

@ -4,23 +4,22 @@ using MyCompanyName.MyProjectName.Web.Components.Toolbar.LoginLink;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Toolbars; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Toolbars;
using Volo.Abp.Users; using Volo.Abp.Users;
namespace MyCompanyName.MyProjectName.Web.Menus namespace MyCompanyName.MyProjectName.Web.Menus;
public class MyProjectNameToolbarContributor : IToolbarContributor
{ {
public class MyProjectNameToolbarContributor : IToolbarContributor public virtual Task ConfigureToolbarAsync(IToolbarConfigurationContext context)
{ {
public virtual Task ConfigureToolbarAsync(IToolbarConfigurationContext context) if (context.Toolbar.Name != StandardToolbars.Main)
{ {
if (context.Toolbar.Name != StandardToolbars.Main)
{
return Task.CompletedTask;
}
if (!context.ServiceProvider.GetRequiredService<ICurrentUser>().IsAuthenticated)
{
context.Toolbar.Items.Add(new ToolbarItem(typeof(LoginLinkViewComponent)));
}
return Task.CompletedTask; return Task.CompletedTask;
} }
if (!context.ServiceProvider.GetRequiredService<ICurrentUser>().IsAuthenticated)
{
context.Toolbar.Items.Add(new ToolbarItem(typeof(LoginLinkViewComponent)));
}
return Task.CompletedTask;
} }
} }

11
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameBrandingProvider.cs

@ -1,11 +1,10 @@
using Volo.Abp.Ui.Branding; using Volo.Abp.Ui.Branding;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
namespace MyCompanyName.MyProjectName.Web namespace MyCompanyName.MyProjectName.Web;
[Dependency(ReplaceServices = true)]
public class MyProjectNameBrandingProvider : DefaultBrandingProvider
{ {
[Dependency(ReplaceServices = true)] public override string AppName => "MyProjectName";
public class MyProjectNameBrandingProvider : DefaultBrandingProvider
{
public override string AppName => "MyProjectName";
}
} }

11
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebAutoMapperProfile.cs

@ -1,12 +1,11 @@
using AutoMapper; using AutoMapper;
namespace MyCompanyName.MyProjectName.Web namespace MyCompanyName.MyProjectName.Web;
public class MyProjectNameWebAutoMapperProfile : Profile
{ {
public class MyProjectNameWebAutoMapperProfile : Profile public MyProjectNameWebAutoMapperProfile()
{ {
public MyProjectNameWebAutoMapperProfile() //Define your AutoMapper configuration here for the Web project.
{
//Define your AutoMapper configuration here for the Web project.
}
} }
} }

355
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebModule.cs

@ -42,226 +42,225 @@ using Volo.Abp.UI;
using Volo.Abp.UI.Navigation; using Volo.Abp.UI.Navigation;
using Volo.Abp.VirtualFileSystem; using Volo.Abp.VirtualFileSystem;
namespace MyCompanyName.MyProjectName.Web namespace MyCompanyName.MyProjectName.Web;
[DependsOn(
typeof(MyProjectNameHttpApiClientModule),
typeof(AbpAspNetCoreAuthenticationOpenIdConnectModule),
typeof(AbpAspNetCoreMvcClientModule),
typeof(AbpAspNetCoreMvcUiBasicThemeModule),
typeof(AbpAutofacModule),
typeof(AbpCachingStackExchangeRedisModule),
typeof(AbpSettingManagementWebModule),
typeof(AbpHttpClientWebModule),
typeof(AbpHttpClientIdentityModelWebModule),
typeof(AbpIdentityWebModule),
typeof(AbpTenantManagementWebModule),
typeof(AbpAspNetCoreSerilogModule),
typeof(AbpSwashbuckleModule)
)]
public class MyProjectNameWebModule : AbpModule
{ {
[DependsOn( public override void PreConfigureServices(ServiceConfigurationContext context)
typeof(MyProjectNameHttpApiClientModule),
typeof(AbpAspNetCoreAuthenticationOpenIdConnectModule),
typeof(AbpAspNetCoreMvcClientModule),
typeof(AbpAspNetCoreMvcUiBasicThemeModule),
typeof(AbpAutofacModule),
typeof(AbpCachingStackExchangeRedisModule),
typeof(AbpSettingManagementWebModule),
typeof(AbpHttpClientWebModule),
typeof(AbpHttpClientIdentityModelWebModule),
typeof(AbpIdentityWebModule),
typeof(AbpTenantManagementWebModule),
typeof(AbpAspNetCoreSerilogModule),
typeof(AbpSwashbuckleModule)
)]
public class MyProjectNameWebModule : AbpModule
{ {
public override void PreConfigureServices(ServiceConfigurationContext context) context.Services.PreConfigure<AbpMvcDataAnnotationsLocalizationOptions>(options =>
{ {
context.Services.PreConfigure<AbpMvcDataAnnotationsLocalizationOptions>(options => options.AddAssemblyResource(
{ typeof(MyProjectNameResource),
options.AddAssemblyResource( typeof(MyProjectNameDomainSharedModule).Assembly,
typeof(MyProjectNameResource), typeof(MyProjectNameApplicationContractsModule).Assembly,
typeof(MyProjectNameDomainSharedModule).Assembly, typeof(MyProjectNameWebModule).Assembly
typeof(MyProjectNameApplicationContractsModule).Assembly, );
typeof(MyProjectNameWebModule).Assembly });
); }
});
}
public override void ConfigureServices(ServiceConfigurationContext context) public override void ConfigureServices(ServiceConfigurationContext context)
{ {
var hostingEnvironment = context.Services.GetHostingEnvironment(); var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.GetConfiguration(); var configuration = context.Services.GetConfiguration();
ConfigureBundles(); ConfigureBundles();
ConfigureCache(); ConfigureCache();
ConfigureDataProtection(context, configuration, hostingEnvironment); ConfigureDataProtection(context, configuration, hostingEnvironment);
ConfigureUrls(configuration); ConfigureUrls(configuration);
ConfigureAuthentication(context, configuration); ConfigureAuthentication(context, configuration);
ConfigureAutoMapper(); ConfigureAutoMapper();
ConfigureVirtualFileSystem(hostingEnvironment); ConfigureVirtualFileSystem(hostingEnvironment);
ConfigureNavigationServices(configuration); ConfigureNavigationServices(configuration);
ConfigureMultiTenancy(); ConfigureMultiTenancy();
ConfigureSwaggerServices(context.Services); ConfigureSwaggerServices(context.Services);
} }
private void ConfigureBundles() private void ConfigureBundles()
{
Configure<AbpBundlingOptions>(options =>
{ {
Configure<AbpBundlingOptions>(options => options.StyleBundles.Configure(
{ BasicThemeBundles.Styles.Global,
options.StyleBundles.Configure( bundle =>
BasicThemeBundles.Styles.Global, {
bundle => bundle.AddFiles("/global-styles.css");
{ }
bundle.AddFiles("/global-styles.css"); );
} });
); }
});
}
private void ConfigureCache() private void ConfigureCache()
{
Configure<AbpDistributedCacheOptions>(options =>
{ {
Configure<AbpDistributedCacheOptions>(options => options.KeyPrefix = "MyProjectName:";
{ });
options.KeyPrefix = "MyProjectName:"; }
});
}
private void ConfigureUrls(IConfiguration configuration) private void ConfigureUrls(IConfiguration configuration)
{
Configure<AppUrlOptions>(options =>
{ {
Configure<AppUrlOptions>(options => options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"];
{ });
options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"]; }
});
}
private void ConfigureMultiTenancy() private void ConfigureMultiTenancy()
{
Configure<AbpMultiTenancyOptions>(options =>
{ {
Configure<AbpMultiTenancyOptions>(options => options.IsEnabled = MultiTenancyConsts.IsEnabled;
{ });
options.IsEnabled = MultiTenancyConsts.IsEnabled; }
});
}
private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration) private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration)
{ {
context.Services.AddAuthentication(options => context.Services.AddAuthentication(options =>
{ {
options.DefaultScheme = "Cookies"; options.DefaultScheme = "Cookies";
options.DefaultChallengeScheme = "oidc"; options.DefaultChallengeScheme = "oidc";
}) })
.AddCookie("Cookies", options => .AddCookie("Cookies", options =>
{ {
options.ExpireTimeSpan = TimeSpan.FromDays(365); options.ExpireTimeSpan = TimeSpan.FromDays(365);
}) })
.AddAbpOpenIdConnect("oidc", options => .AddAbpOpenIdConnect("oidc", options =>
{ {
options.Authority = configuration["AuthServer:Authority"]; options.Authority = configuration["AuthServer:Authority"];
options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]); options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]);
options.ResponseType = OpenIdConnectResponseType.CodeIdToken; options.ResponseType = OpenIdConnectResponseType.CodeIdToken;
options.ClientId = configuration["AuthServer:ClientId"]; options.ClientId = configuration["AuthServer:ClientId"];
options.ClientSecret = configuration["AuthServer:ClientSecret"]; options.ClientSecret = configuration["AuthServer:ClientSecret"];
options.SaveTokens = true; options.SaveTokens = true;
options.GetClaimsFromUserInfoEndpoint = true; options.GetClaimsFromUserInfoEndpoint = true;
options.Scope.Add("role"); options.Scope.Add("role");
options.Scope.Add("email"); options.Scope.Add("email");
options.Scope.Add("phone"); options.Scope.Add("phone");
options.Scope.Add("MyProjectName"); options.Scope.Add("MyProjectName");
}); });
} }
private void ConfigureAutoMapper() private void ConfigureAutoMapper()
{
Configure<AbpAutoMapperOptions>(options =>
{ {
Configure<AbpAutoMapperOptions>(options => options.AddMaps<MyProjectNameWebModule>();
{ });
options.AddMaps<MyProjectNameWebModule>(); }
});
}
private void ConfigureVirtualFileSystem(IWebHostEnvironment hostingEnvironment) private void ConfigureVirtualFileSystem(IWebHostEnvironment hostingEnvironment)
{
if (hostingEnvironment.IsDevelopment())
{ {
if (hostingEnvironment.IsDevelopment()) Configure<AbpVirtualFileSystemOptions>(options =>
{ {
Configure<AbpVirtualFileSystemOptions>(options =>
{
//<TEMPLATE-REMOVE> //<TEMPLATE-REMOVE>
options.FileSets.ReplaceEmbeddedByPhysical<AbpUiModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.UI", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical<AbpUiModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.UI", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiBootstrapModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Bootstrap", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiBootstrapModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Bootstrap", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiThemeSharedModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiThemeSharedModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiBasicThemeModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}basic-theme{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiBasicThemeModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}basic-theme{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpPermissionManagementWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}permission-management{0}src{0}Volo.Abp.PermissionManagement.Web", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical<AbpPermissionManagementWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}permission-management{0}src{0}Volo.Abp.PermissionManagement.Web", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpIdentityWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}identity{0}src{0}Volo.Abp.Identity.Web", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical<AbpIdentityWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}identity{0}src{0}Volo.Abp.Identity.Web", Path.DirectorySeparatorChar)));
//</TEMPLATE-REMOVE> //</TEMPLATE-REMOVE>
options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameDomainSharedModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain")); options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameDomainSharedModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain"));
options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameApplicationContractsModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Application.Contracts")); options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameApplicationContractsModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Application.Contracts"));
options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameWebModule>(hostingEnvironment.ContentRootPath); options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameWebModule>(hostingEnvironment.ContentRootPath);
});
}
}
private void ConfigureNavigationServices(IConfiguration configuration)
{
Configure<AbpNavigationOptions>(options =>
{
options.MenuContributors.Add(new MyProjectNameMenuContributor(configuration));
});
Configure<AbpToolbarOptions>(options =>
{
options.Contributors.Add(new MyProjectNameToolbarContributor());
}); });
} }
}
private void ConfigureSwaggerServices(IServiceCollection services) private void ConfigureNavigationServices(IConfiguration configuration)
{
Configure<AbpNavigationOptions>(options =>
{ {
services.AddAbpSwaggerGen( options.MenuContributors.Add(new MyProjectNameMenuContributor(configuration));
options => });
{
options.SwaggerDoc("v1", new OpenApiInfo { Title = "MyProjectName API", Version = "v1" });
options.DocInclusionPredicate((docName, description) => true);
options.CustomSchemaIds(type => type.FullName);
}
);
}
private void ConfigureDataProtection( Configure<AbpToolbarOptions>(options =>
ServiceConfigurationContext context,
IConfiguration configuration,
IWebHostEnvironment hostingEnvironment)
{ {
var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("MyProjectName"); options.Contributors.Add(new MyProjectNameToolbarContributor());
if (!hostingEnvironment.IsDevelopment()) });
}
private void ConfigureSwaggerServices(IServiceCollection services)
{
services.AddAbpSwaggerGen(
options =>
{ {
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); options.SwaggerDoc("v1", new OpenApiInfo { Title = "MyProjectName API", Version = "v1" });
dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys"); options.DocInclusionPredicate((docName, description) => true);
options.CustomSchemaIds(type => type.FullName);
} }
} );
}
public override void OnApplicationInitialization(ApplicationInitializationContext context) private void ConfigureDataProtection(
ServiceConfigurationContext context,
IConfiguration configuration,
IWebHostEnvironment hostingEnvironment)
{
var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("MyProjectName");
if (!hostingEnvironment.IsDevelopment())
{ {
var app = context.GetApplicationBuilder(); var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]);
var env = context.GetEnvironment(); dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys");
}
}
if (env.IsDevelopment()) public override void OnApplicationInitialization(ApplicationInitializationContext context)
{ {
app.UseDeveloperExceptionPage(); var app = context.GetApplicationBuilder();
} var env = context.GetEnvironment();
app.UseAbpRequestLocalization(); if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
if (!env.IsDevelopment()) app.UseAbpRequestLocalization();
{
app.UseErrorPage();
}
app.UseCorrelationId(); if (!env.IsDevelopment())
app.UseStaticFiles(); {
app.UseRouting(); app.UseErrorPage();
app.UseAuthentication(); }
if (MultiTenancyConsts.IsEnabled) app.UseCorrelationId();
{ app.UseStaticFiles();
app.UseMultiTenancy(); app.UseRouting();
} app.UseAuthentication();
app.UseAuthorization(); if (MultiTenancyConsts.IsEnabled)
app.UseSwagger(); {
app.UseAbpSwaggerUI(options => app.UseMultiTenancy();
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "MyProjectName API");
});
app.UseAbpSerilogEnrichers();
app.UseConfiguredEndpoints();
} }
app.UseAuthorization();
app.UseSwagger();
app.UseAbpSwaggerUI(options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "MyProjectName API");
});
app.UseAbpSerilogEnrichers();
app.UseConfiguredEndpoints();
} }
} }

21
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Pages/Index.cshtml.cs

@ -1,18 +1,17 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication;
namespace MyCompanyName.MyProjectName.Web.Pages namespace MyCompanyName.MyProjectName.Web.Pages;
public class IndexModel : MyProjectNamePageModel
{ {
public class IndexModel : MyProjectNamePageModel public void OnGet()
{ {
public void OnGet()
{
}
public async Task OnPostLoginAsync()
{
await HttpContext.ChallengeAsync("oidc");
}
} }
}
public async Task OnPostLoginAsync()
{
await HttpContext.ChallengeAsync("oidc");
}
}

13
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Pages/MyProjectNamePageModel.cs

@ -1,13 +1,12 @@
using MyCompanyName.MyProjectName.Localization; using MyCompanyName.MyProjectName.Localization;
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; using Volo.Abp.AspNetCore.Mvc.UI.RazorPages;
namespace MyCompanyName.MyProjectName.Web.Pages namespace MyCompanyName.MyProjectName.Web.Pages;
public abstract class MyProjectNamePageModel : AbpPageModel
{ {
public abstract class MyProjectNamePageModel : AbpPageModel protected MyProjectNamePageModel()
{ {
protected MyProjectNamePageModel() LocalizationResourceType = typeof(MyProjectNameResource);
{
LocalizationResourceType = typeof(MyProjectNameResource);
}
} }
} }

65
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Program.cs

@ -5,52 +5,51 @@ using Microsoft.Extensions.Hosting;
using Serilog; using Serilog;
using Serilog.Events; using Serilog.Events;
namespace MyCompanyName.MyProjectName.Web namespace MyCompanyName.MyProjectName.Web;
public class Program
{ {
public class Program public static int Main(string[] args)
{ {
public static int Main(string[] args) Log.Logger = new LoggerConfiguration()
{
Log.Logger = new LoggerConfiguration()
#if DEBUG #if DEBUG
.MinimumLevel.Debug() .MinimumLevel.Debug()
#else #else
.MinimumLevel.Information() .MinimumLevel.Information()
#endif #endif
.MinimumLevel.Override("Microsoft", LogEventLevel.Information) .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) .MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
.Enrich.FromLogContext() .Enrich.FromLogContext()
.WriteTo.Async(c => c.File("Logs/logs.txt")) .WriteTo.Async(c => c.File("Logs/logs.txt"))
#if DEBUG #if DEBUG
.WriteTo.Async(c => c.Console()) .WriteTo.Async(c => c.Console())
#endif #endif
.CreateLogger(); .CreateLogger();
try try
{ {
Log.Information("Starting web host."); Log.Information("Starting web host.");
CreateHostBuilder(args).Build().Run(); CreateHostBuilder(args).Build().Run();
return 0; return 0;
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Fatal(ex, "Host terminated unexpectedly!"); Log.Fatal(ex, "Host terminated unexpectedly!");
return 1; return 1;
} }
finally finally
{ {
Log.CloseAndFlush(); Log.CloseAndFlush();
}
} }
internal static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.AddAppSettingsSecretsJson()
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.UseAutofac()
.UseSerilog();
} }
internal static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.AddAppSettingsSecretsJson()
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.UseAutofac()
.UseSerilog();
} }

19
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Startup.cs

@ -2,18 +2,17 @@
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace MyCompanyName.MyProjectName.Web namespace MyCompanyName.MyProjectName.Web;
public class Startup
{ {
public class Startup public void ConfigureServices(IServiceCollection services)
{ {
public void ConfigureServices(IServiceCollection services) services.AddApplication<MyProjectNameWebModule>();
{ }
services.AddApplication<MyProjectNameWebModule>();
}
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{ {
app.InitializeApplication(); app.InitializeApplication();
}
} }
} }

63
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Menus/MyProjectNameMenuContributor.cs

@ -6,45 +6,44 @@ using Volo.Abp.SettingManagement.Web.Navigation;
using Volo.Abp.TenantManagement.Web.Navigation; using Volo.Abp.TenantManagement.Web.Navigation;
using Volo.Abp.UI.Navigation; using Volo.Abp.UI.Navigation;
namespace MyCompanyName.MyProjectName.Web.Menus namespace MyCompanyName.MyProjectName.Web.Menus;
public class MyProjectNameMenuContributor : IMenuContributor
{ {
public class MyProjectNameMenuContributor : IMenuContributor public async Task ConfigureMenuAsync(MenuConfigurationContext context)
{ {
public async Task ConfigureMenuAsync(MenuConfigurationContext context) if (context.Menu.Name == StandardMenus.Main)
{ {
if (context.Menu.Name == StandardMenus.Main) await ConfigureMainMenuAsync(context);
{
await ConfigureMainMenuAsync(context);
}
} }
}
private async Task ConfigureMainMenuAsync(MenuConfigurationContext context) private async Task ConfigureMainMenuAsync(MenuConfigurationContext context)
{ {
var administration = context.Menu.GetAdministration(); var administration = context.Menu.GetAdministration();
var l = context.GetLocalizer<MyProjectNameResource>(); var l = context.GetLocalizer<MyProjectNameResource>();
context.Menu.Items.Insert( context.Menu.Items.Insert(
0, 0,
new ApplicationMenuItem( new ApplicationMenuItem(
MyProjectNameMenus.Home, MyProjectNameMenus.Home,
l["Menu:Home"], l["Menu:Home"],
"~/", "~/",
icon: "fas fa-home", icon: "fas fa-home",
order: 0 order: 0
) )
); );
if (MultiTenancyConsts.IsEnabled)
{
administration.SetSubItemOrder(TenantManagementMenuNames.GroupName, 1);
}
else
{
administration.TryRemoveMenuItem(TenantManagementMenuNames.GroupName);
}
administration.SetSubItemOrder(IdentityMenuNames.GroupName, 2); if (MultiTenancyConsts.IsEnabled)
administration.SetSubItemOrder(SettingManagementMenuNames.GroupName, 3); {
administration.SetSubItemOrder(TenantManagementMenuNames.GroupName, 1);
}
else
{
administration.TryRemoveMenuItem(TenantManagementMenuNames.GroupName);
} }
administration.SetSubItemOrder(IdentityMenuNames.GroupName, 2);
administration.SetSubItemOrder(SettingManagementMenuNames.GroupName, 3);
} }
} }

15
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Menus/MyProjectNameMenus.cs

@ -1,11 +1,10 @@
namespace MyCompanyName.MyProjectName.Web.Menus namespace MyCompanyName.MyProjectName.Web.Menus;
public class MyProjectNameMenus
{ {
public class MyProjectNameMenus private const string Prefix = "MyProjectName";
{ public const string Home = Prefix + ".Home";
private const string Prefix = "MyProjectName";
public const string Home = Prefix + ".Home";
//Add your menu items here... //Add your menu items here...
} }
}

11
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameBrandingProvider.cs

@ -1,11 +1,10 @@
using Volo.Abp.Ui.Branding; using Volo.Abp.Ui.Branding;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
namespace MyCompanyName.MyProjectName.Web namespace MyCompanyName.MyProjectName.Web;
[Dependency(ReplaceServices = true)]
public class MyProjectNameBrandingProvider : DefaultBrandingProvider
{ {
[Dependency(ReplaceServices = true)] public override string AppName => "MyProjectName";
public class MyProjectNameBrandingProvider : DefaultBrandingProvider
{
public override string AppName => "MyProjectName";
}
} }

11
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebAutoMapperProfile.cs

@ -1,12 +1,11 @@
using AutoMapper; using AutoMapper;
namespace MyCompanyName.MyProjectName.Web namespace MyCompanyName.MyProjectName.Web;
public class MyProjectNameWebAutoMapperProfile : Profile
{ {
public class MyProjectNameWebAutoMapperProfile : Profile public MyProjectNameWebAutoMapperProfile()
{ {
public MyProjectNameWebAutoMapperProfile() //Define your AutoMapper configuration here for the Web project.
{
//Define your AutoMapper configuration here for the Web project.
}
} }
} }

351
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs

@ -38,217 +38,216 @@ using Volo.Abp.UI;
using Volo.Abp.UI.Navigation; using Volo.Abp.UI.Navigation;
using Volo.Abp.VirtualFileSystem; using Volo.Abp.VirtualFileSystem;
namespace MyCompanyName.MyProjectName.Web namespace MyCompanyName.MyProjectName.Web;
[DependsOn(
typeof(MyProjectNameHttpApiModule),
typeof(MyProjectNameApplicationModule),
typeof(MyProjectNameEntityFrameworkCoreModule),
typeof(AbpAutofacModule),
typeof(AbpIdentityWebModule),
typeof(AbpSettingManagementWebModule),
typeof(AbpAccountWebIdentityServerModule),
typeof(AbpAspNetCoreMvcUiBasicThemeModule),
typeof(AbpAspNetCoreAuthenticationJwtBearerModule),
typeof(AbpTenantManagementWebModule),
typeof(AbpAspNetCoreSerilogModule),
typeof(AbpSwashbuckleModule)
)]
public class MyProjectNameWebModule : AbpModule
{ {
[DependsOn( public override void PreConfigureServices(ServiceConfigurationContext context)
typeof(MyProjectNameHttpApiModule),
typeof(MyProjectNameApplicationModule),
typeof(MyProjectNameEntityFrameworkCoreModule),
typeof(AbpAutofacModule),
typeof(AbpIdentityWebModule),
typeof(AbpSettingManagementWebModule),
typeof(AbpAccountWebIdentityServerModule),
typeof(AbpAspNetCoreMvcUiBasicThemeModule),
typeof(AbpAspNetCoreAuthenticationJwtBearerModule),
typeof(AbpTenantManagementWebModule),
typeof(AbpAspNetCoreSerilogModule),
typeof(AbpSwashbuckleModule)
)]
public class MyProjectNameWebModule : AbpModule
{ {
public override void PreConfigureServices(ServiceConfigurationContext context) context.Services.PreConfigure<AbpMvcDataAnnotationsLocalizationOptions>(options =>
{ {
context.Services.PreConfigure<AbpMvcDataAnnotationsLocalizationOptions>(options => options.AddAssemblyResource(
{ typeof(MyProjectNameResource),
options.AddAssemblyResource( typeof(MyProjectNameDomainModule).Assembly,
typeof(MyProjectNameResource), typeof(MyProjectNameDomainSharedModule).Assembly,
typeof(MyProjectNameDomainModule).Assembly, typeof(MyProjectNameApplicationModule).Assembly,
typeof(MyProjectNameDomainSharedModule).Assembly, typeof(MyProjectNameApplicationContractsModule).Assembly,
typeof(MyProjectNameApplicationModule).Assembly, typeof(MyProjectNameWebModule).Assembly
typeof(MyProjectNameApplicationContractsModule).Assembly, );
typeof(MyProjectNameWebModule).Assembly });
); }
});
}
public override void ConfigureServices(ServiceConfigurationContext context)
{
var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.GetConfiguration();
ConfigureUrls(configuration);
ConfigureBundles();
ConfigureAuthentication(context, configuration);
ConfigureAutoMapper();
ConfigureVirtualFileSystem(hostingEnvironment);
ConfigureLocalizationServices();
ConfigureNavigationServices();
ConfigureAutoApiControllers();
ConfigureSwaggerServices(context.Services);
}
private void ConfigureUrls(IConfiguration configuration) public override void ConfigureServices(ServiceConfigurationContext context)
{ {
Configure<AppUrlOptions>(options => var hostingEnvironment = context.Services.GetHostingEnvironment();
{ var configuration = context.Services.GetConfiguration();
options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"];
}); ConfigureUrls(configuration);
} ConfigureBundles();
ConfigureAuthentication(context, configuration);
ConfigureAutoMapper();
ConfigureVirtualFileSystem(hostingEnvironment);
ConfigureLocalizationServices();
ConfigureNavigationServices();
ConfigureAutoApiControllers();
ConfigureSwaggerServices(context.Services);
}
private void ConfigureBundles() private void ConfigureUrls(IConfiguration configuration)
{
Configure<AppUrlOptions>(options =>
{ {
Configure<AbpBundlingOptions>(options => options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"];
{ });
options.StyleBundles.Configure( }
BasicThemeBundles.Styles.Global,
bundle =>
{
bundle.AddFiles("/global-styles.css");
}
);
});
}
private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration) private void ConfigureBundles()
{
Configure<AbpBundlingOptions>(options =>
{ {
context.Services.AddAuthentication() options.StyleBundles.Configure(
.AddJwtBearer(options => BasicThemeBundles.Styles.Global,
bundle =>
{ {
options.Authority = configuration["AuthServer:Authority"]; bundle.AddFiles("/global-styles.css");
options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]); }
options.Audience = "MyProjectName"; );
}); });
} }
private void ConfigureAutoMapper() private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration)
{ {
Configure<AbpAutoMapperOptions>(options => context.Services.AddAuthentication()
.AddJwtBearer(options =>
{ {
options.AddMaps<MyProjectNameWebModule>(); options.Authority = configuration["AuthServer:Authority"];
options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]);
options.Audience = "MyProjectName";
}); });
} }
private void ConfigureVirtualFileSystem(IWebHostEnvironment hostingEnvironment) private void ConfigureAutoMapper()
{
Configure<AbpAutoMapperOptions>(options =>
{ {
if (hostingEnvironment.IsDevelopment()) options.AddMaps<MyProjectNameWebModule>();
});
}
private void ConfigureVirtualFileSystem(IWebHostEnvironment hostingEnvironment)
{
if (hostingEnvironment.IsDevelopment())
{
Configure<AbpVirtualFileSystemOptions>(options =>
{ {
Configure<AbpVirtualFileSystemOptions>(options =>
{
//<TEMPLATE-REMOVE> //<TEMPLATE-REMOVE>
options.FileSets.ReplaceEmbeddedByPhysical<AbpUiModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.UI", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical<AbpUiModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.UI", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiBootstrapModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Bootstrap", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiBootstrapModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Bootstrap", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiThemeSharedModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiThemeSharedModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiBasicThemeModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}basic-theme{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiBasicThemeModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}basic-theme{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiMultiTenancyModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiMultiTenancyModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpPermissionManagementWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}permission-management{0}src{0}Volo.Abp.PermissionManagement.Web", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical<AbpPermissionManagementWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}permission-management{0}src{0}Volo.Abp.PermissionManagement.Web", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpFeatureManagementWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}feature-management{0}src{0}Volo.Abp.FeatureManagement.Web", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical<AbpFeatureManagementWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}feature-management{0}src{0}Volo.Abp.FeatureManagement.Web", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpIdentityWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}identity{0}src{0}Volo.Abp.Identity.Web", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical<AbpIdentityWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}identity{0}src{0}Volo.Abp.Identity.Web", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpAccountWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}account{0}src{0}Volo.Abp.Account.Web", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical<AbpAccountWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}account{0}src{0}Volo.Abp.Account.Web", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpTenantManagementWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}tenant-management{0}src{0}Volo.Abp.TenantManagement.Web", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical<AbpTenantManagementWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}tenant-management{0}src{0}Volo.Abp.TenantManagement.Web", Path.DirectorySeparatorChar)));
//</TEMPLATE-REMOVE> //</TEMPLATE-REMOVE>
options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameDomainSharedModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain.Shared")); options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameDomainSharedModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain.Shared"));
options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameDomainModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain")); options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameDomainModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain"));
options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameApplicationContractsModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Application.Contracts")); options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameApplicationContractsModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Application.Contracts"));
options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameApplicationModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Application")); options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameApplicationModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Application"));
options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameWebModule>(hostingEnvironment.ContentRootPath); options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameWebModule>(hostingEnvironment.ContentRootPath);
});
}
}
private void ConfigureLocalizationServices()
{
Configure<AbpLocalizationOptions>(options =>
{
options.Languages.Add(new LanguageInfo("ar", "ar", "العربية"));
options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština"));
options.Languages.Add(new LanguageInfo("en", "en", "English"));
options.Languages.Add(new LanguageInfo("en-GB", "en-GB", "English (UK)"));
options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar"));
options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish"));
options.Languages.Add(new LanguageInfo("fr", "fr", "Français"));
options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in"));
options.Languages.Add(new LanguageInfo("is", "is", "Icelandic", "is"));
options.Languages.Add(new LanguageInfo("it", "it", "Italiano", "it"));
options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português"));
options.Languages.Add(new LanguageInfo("ro-RO", "ro-RO", "Română"));
options.Languages.Add(new LanguageInfo("ru", "ru", "Русский"));
options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak"));
options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe"));
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文"));
options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文"));
options.Languages.Add(new LanguageInfo("de-DE", "de-DE", "Deutsch", "de"));
options.Languages.Add(new LanguageInfo("es", "es", "Español"));
});
}
private void ConfigureNavigationServices()
{
Configure<AbpNavigationOptions>(options =>
{
options.MenuContributors.Add(new MyProjectNameMenuContributor());
}); });
} }
}
private void ConfigureAutoApiControllers() private void ConfigureLocalizationServices()
{
Configure<AbpLocalizationOptions>(options =>
{ {
Configure<AbpAspNetCoreMvcOptions>(options => options.Languages.Add(new LanguageInfo("ar", "ar", "العربية"));
{ options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština"));
options.ConventionalControllers.Create(typeof(MyProjectNameApplicationModule).Assembly); options.Languages.Add(new LanguageInfo("en", "en", "English"));
}); options.Languages.Add(new LanguageInfo("en-GB", "en-GB", "English (UK)"));
} options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar"));
options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish"));
options.Languages.Add(new LanguageInfo("fr", "fr", "Français"));
options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in"));
options.Languages.Add(new LanguageInfo("is", "is", "Icelandic", "is"));
options.Languages.Add(new LanguageInfo("it", "it", "Italiano", "it"));
options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português"));
options.Languages.Add(new LanguageInfo("ro-RO", "ro-RO", "Română"));
options.Languages.Add(new LanguageInfo("ru", "ru", "Русский"));
options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak"));
options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe"));
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文"));
options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文"));
options.Languages.Add(new LanguageInfo("de-DE", "de-DE", "Deutsch", "de"));
options.Languages.Add(new LanguageInfo("es", "es", "Español"));
});
}
private void ConfigureSwaggerServices(IServiceCollection services) private void ConfigureNavigationServices()
{
Configure<AbpNavigationOptions>(options =>
{ {
services.AddAbpSwaggerGen( options.MenuContributors.Add(new MyProjectNameMenuContributor());
options => });
{ }
options.SwaggerDoc("v1", new OpenApiInfo { Title = "MyProjectName API", Version = "v1" });
options.DocInclusionPredicate((docName, description) => true);
options.CustomSchemaIds(type => type.FullName);
}
);
}
public override void OnApplicationInitialization(ApplicationInitializationContext context) private void ConfigureAutoApiControllers()
{
Configure<AbpAspNetCoreMvcOptions>(options =>
{ {
var app = context.GetApplicationBuilder(); options.ConventionalControllers.Create(typeof(MyProjectNameApplicationModule).Assembly);
var env = context.GetEnvironment(); });
}
if (env.IsDevelopment()) private void ConfigureSwaggerServices(IServiceCollection services)
{
services.AddAbpSwaggerGen(
options =>
{ {
app.UseDeveloperExceptionPage(); options.SwaggerDoc("v1", new OpenApiInfo { Title = "MyProjectName API", Version = "v1" });
options.DocInclusionPredicate((docName, description) => true);
options.CustomSchemaIds(type => type.FullName);
} }
);
}
app.UseAbpRequestLocalization(); public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
if (!env.IsDevelopment()) if (env.IsDevelopment())
{ {
app.UseErrorPage(); app.UseDeveloperExceptionPage();
} }
app.UseCorrelationId(); app.UseAbpRequestLocalization();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseJwtTokenMiddleware();
if (MultiTenancyConsts.IsEnabled) if (!env.IsDevelopment())
{ {
app.UseMultiTenancy(); app.UseErrorPage();
} }
app.UseUnitOfWork(); app.UseCorrelationId();
app.UseIdentityServer(); app.UseStaticFiles();
app.UseAuthorization(); app.UseRouting();
app.UseSwagger(); app.UseAuthentication();
app.UseAbpSwaggerUI(options => app.UseJwtTokenMiddleware();
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "MyProjectName API"); if (MultiTenancyConsts.IsEnabled)
}); {
app.UseAuditing(); app.UseMultiTenancy();
app.UseAbpSerilogEnrichers();
app.UseConfiguredEndpoints();
} }
app.UseUnitOfWork();
app.UseIdentityServer();
app.UseAuthorization();
app.UseSwagger();
app.UseAbpSwaggerUI(options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "MyProjectName API");
});
app.UseAuditing();
app.UseAbpSerilogEnrichers();
app.UseConfiguredEndpoints();
} }
} }

13
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/Index.cshtml.cs

@ -1,10 +1,9 @@
namespace MyCompanyName.MyProjectName.Web.Pages namespace MyCompanyName.MyProjectName.Web.Pages;
public class IndexModel : MyProjectNamePageModel
{ {
public class IndexModel : MyProjectNamePageModel public void OnGet()
{ {
public void OnGet()
{
}
} }
} }

17
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/MyProjectNamePageModel.cs

@ -1,15 +1,14 @@
using MyCompanyName.MyProjectName.Localization; using MyCompanyName.MyProjectName.Localization;
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; using Volo.Abp.AspNetCore.Mvc.UI.RazorPages;
namespace MyCompanyName.MyProjectName.Web.Pages namespace MyCompanyName.MyProjectName.Web.Pages;
/* Inherit your PageModel classes from this class.
*/
public abstract class MyProjectNamePageModel : AbpPageModel
{ {
/* Inherit your PageModel classes from this class. protected MyProjectNamePageModel()
*/
public abstract class MyProjectNamePageModel : AbpPageModel
{ {
protected MyProjectNamePageModel() LocalizationResourceType = typeof(MyProjectNameResource);
{
LocalizationResourceType = typeof(MyProjectNameResource);
}
} }
} }

65
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Program.cs

@ -5,52 +5,51 @@ using Microsoft.Extensions.Hosting;
using Serilog; using Serilog;
using Serilog.Events; using Serilog.Events;
namespace MyCompanyName.MyProjectName.Web namespace MyCompanyName.MyProjectName.Web;
public class Program
{ {
public class Program public static int Main(string[] args)
{ {
public static int Main(string[] args) Log.Logger = new LoggerConfiguration()
{
Log.Logger = new LoggerConfiguration()
#if DEBUG #if DEBUG
.MinimumLevel.Debug() .MinimumLevel.Debug()
#else #else
.MinimumLevel.Information() .MinimumLevel.Information()
#endif #endif
.MinimumLevel.Override("Microsoft", LogEventLevel.Information) .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) .MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
.Enrich.FromLogContext() .Enrich.FromLogContext()
.WriteTo.Async(c => c.File("Logs/logs.txt")) .WriteTo.Async(c => c.File("Logs/logs.txt"))
#if DEBUG #if DEBUG
.WriteTo.Async(c => c.Console()) .WriteTo.Async(c => c.Console())
#endif #endif
.CreateLogger(); .CreateLogger();
try try
{ {
Log.Information("Starting web host."); Log.Information("Starting web host.");
CreateHostBuilder(args).Build().Run(); CreateHostBuilder(args).Build().Run();
return 0; return 0;
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Fatal(ex, "Host terminated unexpectedly!"); Log.Fatal(ex, "Host terminated unexpectedly!");
return 1; return 1;
} }
finally finally
{ {
Log.CloseAndFlush(); Log.CloseAndFlush();
}
} }
internal static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.AddAppSettingsSecretsJson()
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.UseAutofac()
.UseSerilog();
} }
internal static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.AddAppSettingsSecretsJson()
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.UseAutofac()
.UseSerilog();
} }

19
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Startup.cs

@ -1,18 +1,17 @@
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
namespace MyCompanyName.MyProjectName.Web namespace MyCompanyName.MyProjectName.Web;
public class Startup
{ {
public class Startup public void ConfigureServices(IServiceCollection services)
{ {
public void ConfigureServices(IServiceCollection services) services.AddApplication<MyProjectNameWebModule>();
{ }
services.AddApplication<MyProjectNameWebModule>();
}
public void Configure(IApplicationBuilder app) public void Configure(IApplicationBuilder app)
{ {
app.InitializeApplication(); app.InitializeApplication();
}
} }
} }

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save