https://github.com/abpframework/abp/blob/dev/docs/en/Community-Articles/2024-11-25-Global-Assets/POST.md
你好
现在根据文档添加全局js文件 但是无法生成global.js
blazor 项目添加了
typeof(AbpAspNetCoreMvcUiBundlingModule)
,typeof(AbpAuditLoggingBlazorWebAssemblyBundlingModule)
blazor.client项目代码 public class MonacoBundleScriptContributor : BundleContributor { public override void ConfigureBundle(BundleConfigurationContext context) { context.Files.Add(new BundleFile("_content/BlazorMonaco/jsInterop.js", true)); context.Files.Add(new BundleFile("_content/BlazorMonaco/lib/monaco-editor/min/vs/loader.js", true)); context.Files.Add(new BundleFile("_content/BlazorMonaco/lib/monaco-editor/min/vs/editor/editor.main.js", true));
//context.Files.Add(new BundleFile("/BlazorMonaco/jsInterop.js", true));
//context.Files.Add(new BundleFile("/BlazorMonaco/monaco-editor/min/vs/loader.js", true));
//context.Files.Add(new BundleFile("/BlazorMonaco/monaco-editor/min/vs/editor/editor.main.js", true));
}
}
private void ConfigureBundles()
{
Configure<AbpBundlingOptions>(options =>
{
var globalScripts = options.ScriptBundles.Get(BlazorWebAssemblyStandardBundles.Scripts.Global);
globalScripts.AddContributors(typeof(MonacoBundleScriptContributor));
});
}
项目启动后无法访问global.js
9 Answer(s)
-
0
- Solution Based on the new Global Assets feature, global.js is not a physical file you build with abp bundle anymore; it is generated dynamically by the host (server) project at runtime and served from a virtual file provider. To make https://localhost/global.js available in a Blazor Web App (ABP v10), ensure all of the following:
Use the correct bundling modules on the host (server) project
- Add a dependency to one of the WebAssembly theme bundling modules (choose the one you use):
- AbpAspNetCoreComponentsWebAssemblyLeptonXLiteThemeBundlingModule
- AbpAspNetCoreComponentsWebAssemblyLeptonXThemeBundlingModule
- AbpAspNetCoreComponentsWebAssemblyBasicThemeBundlingModule
- AbpAspNetCoreComponentsWebAssemblyLeptonThemeBundlingModule
- Also keep AbpAspNetCoreMvcUiBundlingModule on the host project; it publishes the global assets as virtual files.
Example:
- Add a dependency to one of the WebAssembly theme bundling modules (choose the one you use):
[DependsOn( typeof(AbpAutofacModule), typeof(AbpAspNetCoreMvcUiBundlingModule), typeof(AbpAspNetCoreComponentsWebAssemblyLeptonXLiteThemeBundlingModule) // + any commercial WebAssembly bundling modules you use, e.g.: // typeof(AbpAuditLoggingBlazorWebAssemblyBundlingModule) )] public class MyProjectNameBlazorModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { // Add services to the container context.Services.AddRazorComponents() .AddInteractiveWebAssemblyComponents(); } public override void OnApplicationInitialization(ApplicationInitializationContext context) { var app = context.GetApplicationBuilder(); var env = context.GetEnvironment(); if (env.IsDevelopment()) { app.UseWebAssemblyDebugging(); } else { app.UseHsts(); } app.UseHttpsRedirection(); // IMPORTANT: maps static/virtual assets including global.js & global.css app.MapAbpStaticAssets(); app.UseRouting(); app.UseAntiforgery(); app.UseConfiguredEndpoints(builder => { builder.MapRazorComponents<App>() .AddInteractiveWebAssemblyRenderMode() .AddAdditionalAssemblies(WebAppAdditionalAssembliesHelper.GetAssemblies<MyProjectNameBlazorClientModule>()); }); } }- Put your bundle contributor in the client project and contribute to the correct bundle name
- In the Blazor.Client project, register your contributor to BlazorWebAssemblyStandardBundles.Scripts.Global:
public class MonacoBundleScriptContributor : BundleContributor { public override void ConfigureBundle(BundleConfigurationContext context) { context.Files.AddIfNotContains("_content/BlazorMonaco/jsInterop.js"); context.Files.AddIfNotContains("_content/BlazorMonaco/lib/monaco-editor/min/vs/loader.js"); context.Files.AddIfNotContains("_content/BlazorMonaco/lib/monaco-editor/min/vs/editor/editor.main.js"); } } // In the same Blazor.Client project (e.g., in your module) private void ConfigureBundles() { Configure<AbpBundlingOptions>(options => { var globalScripts = options.ScriptBundles.Get(BlazorWebAssemblyStandardBundles.Scripts.Global); globalScripts.AddContributors(typeof(MonacoBundleScriptContributor)); }); }Notes:
Use AddIfNotContains and relative paths starting with _content/ for library static files.
Ensure the Blazor.Client project references the BlazorMonaco package so those _content files exist at runtime.
Reference the client project from the host project
- The server (host) project must have a ProjectReference to the Blazor.Client project so it can access its static/virtual contents and build the dynamic global bundle.
Ensure MapAbpStaticAssets is called in the host pipeline
- Without app.MapAbpStaticAssets(), the dynamic virtual files (/global.js and /global.css) won’t be served.
Verify at runtime
- Run the host project and browse:
- https://localhost:PORT/global.js
- https://localhost:PORT/global.css
- If you changed the file names via AbpBundlingOptions.GlobalAssets, use that path accordingly (defaults are global.js and global.css).
- Run the host project and browse:
Common pitfalls to check
- Missing theme WebAssembly bundling module on the host: without it, the bundling pipeline for WebAssembly is not wired, so global.js won’t be produced.
- Contributor registered on the wrong bundle or wrong project: contributors should be registered against BlazorWebAssemblyStandardBundles.Scripts.Global (not MVC bundles) and typically from the Blazor.Client project.
- Not calling MapAbpStaticAssets in the host app.
- Paths incorrect: library static files must be referenced with _content/LibraryName/... and the package must be referenced so the files are available.
- Sources
- https://abp.io/docs/latest/framework/architecture/modularity/basics
- https://docs.abp.io/en/abp/latest/UI/AspNetCore/Bundling-Minification
- https://github.com/abpframework/abp/blob/dev/docs/en/Community-Articles/2024-11-25-Global-Assets/POST.md
This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.
-
0
你好
HTTP请求
global.js返回什么? 后端的日志是?谢谢
-
0
返回404
Request finished HTTP/2 GET https://localhost:44353/Global.js - 404 0 null 123.0308msblazor <ItemGroup> <PackageReference Include="Volo.Abp.AspNetCore.Components.Server.LeptonXTheme" Version="5.0.0" /> <PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonX" Version="5.0.0" /> <PackageReference Include="Volo.Abp.AspNetCore.Components.WebAssembly.LeptonXTheme.Bundling" Version="5.0.0" /> </ItemGroup>
blazor.client <PackageReference Include="Volo.Abp.AspNetCore.Components.WebAssembly.LeptonXTheme" Version="5.0.0" />
-
0
试试
https://localhost:44353/global.js呢?MonacoBundleScriptContributor应该在Blazor项目中如果可能请分享一个简单的项目复现问题
liming.ma@volosoft.com
-
0
using System; using System.Net.Http; using Blazorise; using Blazorise.Bootstrap5; using Blazorise.Icons.FontAwesome; using Microsoft.AspNetCore.Components.WebAssembly.Authentication; using Microsoft.AspNetCore.Components.WebAssembly.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using OpenIddict.Abstractions; using Syncfusion.Blazor; using System; using System.Net.Http; using TechGenius.Blazor.Client.Components.Layout; using TechGenius.Blazor.Client.Navigation; using OpenIddict.Abstractions; using Volo.Abp.AspNetCore.Components.Web; using Volo.Abp.AspNetCore.Components.Web.Theming.Routing; using Volo.Abp.Autofac.WebAssembly; using Volo.Abp.Mapperly; using Volo.Abp.Modularity; using Volo.Abp.UI.Navigation; using Volo.Abp.AspNetCore.Mvc.UI.Bundling; using Volo.Abp.AspNetCore.Components.WebAssembly.Theming.Bundling; using TechGenius.Blazor.Client.Components.Layout; using Volo.Abp.AspNetCore.Components.WebAssembly.LeptonXTheme; using Volo.Abp.AspNetCore.Components.Web.LeptonXTheme; using Volo.Abp.LeptonX.Shared; using Volo.Abp.SettingManagement.Blazor.WebAssembly; using Volo.Abp.FeatureManagement.Blazor.WebAssembly; using Volo.Abp.Account.Pro.Admin.Blazor.WebAssembly; using Volo.Abp.Account.Pro.Public.Blazor.WebAssembly; using Volo.Abp.Identity.Pro.Blazor.Server.WebAssembly; using Volo.Abp.Identity.Pro.Blazor; using Volo.Abp.AuditLogging.Blazor.WebAssembly; using Volo.Abp.Gdpr.Blazor.Extensions; using Volo.Abp.Gdpr.Blazor.WebAssembly; using Volo.Abp.LanguageManagement.Blazor.WebAssembly; using Volo.Abp.OpenIddict.Pro.Blazor.WebAssembly; using Volo.Abp.TextTemplateManagement.Blazor.WebAssembly; using Volo.Saas.Host.Blazor; using Volo.Saas.Host.Blazor.WebAssembly; using Volo.Chat.Blazor.WebAssembly; using Volo.Abp.AspNetCore.Components.Web.LeptonXTheme.Components; using Volo.Abp.AspNetCore.Components.WebAssembly.LeptonXTheme.Bundling; namespace TechGenius.Blazor.Client; [DependsOn( typeof(AbpSettingManagementBlazorWebAssemblyModule), typeof(AbpFeatureManagementBlazorWebAssemblyModule), typeof(AbpAccountAdminBlazorWebAssemblyModule), typeof(AbpAccountPublicBlazorWebAssemblyModule), typeof(AbpIdentityProBlazorWebAssemblyModule), typeof(SaasHostBlazorWebAssemblyModule), typeof(AbpOpenIddictProBlazorWebAssemblyModule), typeof(AbpAuditLoggingBlazorWebAssemblyModule), typeof(AbpGdprBlazorWebAssemblyModule), typeof(TextTemplateManagementBlazorWebAssemblyModule), typeof(LanguageManagementBlazorWebAssemblyModule), typeof(AbpAspNetCoreComponentsWebAssemblyLeptonXThemeBundlingModule), typeof(AbpAspNetCoreComponentsWebAssemblyLeptonXThemeModule), typeof(AbpAutofacWebAssemblyModule), typeof(TechGeniusHttpApiClientModule), typeof(ChatBlazorWebAssemblyModule) ) ] public class TechGeniusBlazorClientModule : AbpModule { public override void PreConfigureServices(ServiceConfigurationContext context) { PreConfigure<AbpAspNetCoreComponentsWebOptions>(options => { options.IsBlazorWebApp = true; }); } public override void ConfigureServices(ServiceConfigurationContext context) { var environment = context.Services.GetSingletonInstance<IWebAssemblyHostEnvironment>(); var builder = context.Services.GetSingletonInstance<WebAssemblyHostBuilder>(); context.Services.AddDevExpressBlazor(); context.Services.AddSyncfusionBlazor(); ConfigureAuthentication(builder); ConfigureImpersonation(context); ConfigureHttpClient(context, environment); ConfigureBlazorise(context); ConfigureRouter(context); ConfigureMenu(context); ConfigureCookieConsent(context); ConfigureTheme(); ConfigureBundles(); //ConfigureAutoMapper(context); } private void ConfigureBundles() { Configure<AbpBundlingOptions>(options => { //var globalScripts = options.ScriptBundles.Get(BlazorWebAssemblyStandardBundles.Scripts.Global); //globalScripts.AddContributors(typeof(MonacoBundleScriptContributor)); //options // .ScriptBundles // .Add("MyGlobalBundle", bundle => // { // bundle.AddFiles( // "_content/BlazorMonaco/jsInterop.js", // "_content/BlazorMonaco/lib/monaco-editor/min/vs/loader.js", // "_content/BlazorMonaco/lib/monaco-editor/min/vs/editor/editor.main.js" // ); // }); //options.ScriptBundles.Configure( ////BlazorWebAssemblyStandardBundles //// BlazorLeptonXThemeBundles //// Or BasicThemeBundles.Scripts.Global //// Or LeptonXLiteThemeBundles.Scripts.Global //// 👇 Depends on the theme you are using //BlazorWebAssemblyStandardBundles.Scripts.Global, //bundle => //{ // bundle.AddContributors(typeof(MonacoBundleScriptContributor)); //}); options.ScriptBundles.Configure( BlazorWebAssemblyStandardBundles.Scripts.Global, bundle => { bundle.AddFiles("_content/BlazorMonaco/jsInterop.js"); bundle.AddFiles("_content/BlazorMonaco/lib/monaco-editor/min/vs/loader.js"); bundle.AddFiles("_content/BlazorMonaco/lib/monaco-editor/min/vs/editor/editor.main.js"); } ); //options.ScriptBundles.Configure( //// Or BasicThemeBundles.Scripts.Global //// Or LeptonXLiteThemeBundles.Scripts.Global //// 👇 Depends on the theme you are using //BlazorLeptonXThemeBundles.Scripts.Global, //bundle => //{ // bundle.AddFiles(new BundleFile("/vue.js", true)); // // 👇 Make sure to add this line // bundle.AddContributors(typeof(Vue3Contributor)); //}); }); } private void ConfigureCookieConsent(ServiceConfigurationContext context) { context.Services.AddAbpCookieConsent(options => { options.IsEnabled = true; options.CookiePolicyUrl = "/CookiePolicy"; options.PrivacyPolicyUrl = "/PrivacyPolicy"; }); } private void ConfigureTheme() { Configure<LeptonXThemeOptions>(options => { options.DefaultStyle = LeptonXStyleNames.System; }); Configure<LeptonXThemeBlazorOptions>(options => { // When Layout is changed, the `options.Parameters["LeptonXTheme.Layout"]` in TechGeniusBlazorModule.cs should be updated accordingly. options.Layout = LeptonXBlazorLayouts.SideMenu; }); } private void ConfigureRouter(ServiceConfigurationContext context) { Configure<AbpRouterOptions>(options => { options.AppAssembly = typeof(TechGeniusBlazorClientModule).Assembly; options.AdditionalAssemblies.Add(typeof(TechGeniusBlazorClientModule).Assembly); }); } private void ConfigureMenu(ServiceConfigurationContext context) { Configure<AbpNavigationOptions>(options => { options.MenuContributors.Add(new TechGeniusMenuContributor(context.Services.GetConfiguration())); }); } private void ConfigureBlazorise(ServiceConfigurationContext context) { context.Services .AddBlazorise(options => { // TODO (IMPORTANT): To use Blazorise, you need a license key. Get your license key directly from Blazorise, follow the instructions at https://abp.io/faq#how-to-get-blazorise-license-key options.ProductToken = "xxx"; }) .AddBootstrap5Providers() .AddFontAwesomeIcons(); } private static void ConfigureAuthentication(WebAssemblyHostBuilder builder) { builder.Services.AddBlazorWebAppServices(); } private void ConfigureImpersonation(ServiceConfigurationContext context) { context.Services.Configure<SaasHostBlazorOptions>(options => { options.EnableTenantImpersonation = true; }); context.Services.Configure<AbpIdentityProBlazorOptions>(options => { options.EnableUserImpersonation = true; }); } private static void ConfigureHttpClient(ServiceConfigurationContext context, IWebAssemblyHostEnvironment environment) { context.Services.AddTransient(sp => new HttpClient { BaseAddress = new Uri(environment.BaseAddress) }); } //private void ConfigureAutoMapper(ServiceConfigurationContext context) //{ // context.Services.AddAutoMapperObjectMapper(); // Configure<AbpAutoMapperOptions>(options => // { // options.AddMaps<TechGeniusBlazorClientModule>(); // }); //} }global.js 也无法访问.移除了MonacoBundleScriptContributor,在client项目直接添加了JS
-
0
namespace TechGenius.Blazor; [DependsOn( typeof(TechGeniusApplicationModule), typeof(TechGeniusEntityFrameworkCoreModule), typeof(TechGeniusHttpApiModule), typeof(AbpAutofacModule), typeof(AbpSwashbuckleModule), typeof(AbpAccountPublicBlazorWebAssemblyBundlingModule), typeof(AbpAccountPublicWebImpersonationModule), typeof(AbpAccountPublicWebOpenIddictModule), typeof(AbpAccountPublicBlazorServerModule), typeof(AbpAccountAdminBlazorServerModule), typeof(AbpIdentityProBlazorServerModule), typeof(TextTemplateManagementBlazorServerModule), typeof(AbpAuditLoggingBlazorServerModule), typeof(AbpAuditLoggingBlazorWebAssemblyBundlingModule), typeof(AbpGdprBlazorServerModule), typeof(AbpOpenIddictProBlazorServerModule), typeof(LanguageManagementBlazorServerModule), typeof(SaasHostBlazorServerModule), typeof(SaasHostBlazorWebAssemblyBundlingModule), typeof(AbpAspNetCoreComponentsServerLeptonXThemeModule), typeof(AbpAspNetCoreComponentsWebAssemblyLeptonXThemeBundlingModule), typeof(AbpAspNetCoreMvcUiLeptonXThemeModule), typeof(AbpAspNetCoreSerilogModule), typeof(ChatBlazorServerModule), typeof(ChatSignalRModule), typeof(AbpAspNetCoreMvcUiBundlingModule) ,typeof(AbpAuditLoggingBlazorWebAssemblyBundlingModule) //,typeof(FileManagementBlazorWebAssemblyBundlingModule) ,typeof(SaasHostBlazorWebAssemblyBundlingModule) // ,typeof(ChatBlazorWebAssemblyBundlingModule) // ,typeof(CmsKitProAdminBlazorWebAssemblyBundlingModule) //typeof(AbpAspNetCoreComponentsWebThemingModule) )] public class TechGeniusBlazorModule : AbpModule { public override void PreConfigureServices(ServiceConfigurationContext context) { var hostingEnvironment = context.Services.GetHostingEnvironment(); var configuration = context.Services.GetConfiguration(); context.Services.AddSyncfusionBlazor(); context.Services.PreConfigure<AbpMvcDataAnnotationsLocalizationOptions>(options => { options.AddAssemblyResource( typeof(TechGeniusResource), typeof(TechGeniusDomainModule).Assembly, typeof(TechGeniusDomainSharedModule).Assembly, typeof(TechGeniusApplicationModule).Assembly, typeof(TechGeniusApplicationContractsModule).Assembly, typeof(TechGeniusBlazorModule).Assembly ); }); PreConfigure<OpenIddictBuilder>(builder => { builder.AddValidation(options => { options.AddAudiences("TechGenius"); options.UseLocalServer(); options.UseAspNetCore(); }); }); if (!hostingEnvironment.IsDevelopment()) { PreConfigure<AbpOpenIddictAspNetCoreOptions>(options => { options.AddDevelopmentEncryptionAndSigningCertificate = false; }); PreConfigure<OpenIddictServerBuilder>(serverBuilder => { serverBuilder.AddProductionEncryptionAndSigningCertificate("openiddict.pfx", configuration["AuthServer:CertificatePassPhrase"]!); serverBuilder.SetIssuer(new Uri(configuration["AuthServer:Authority"]!)); }); } PreConfigure<AbpAspNetCoreComponentsWebOptions>(options => { options.IsBlazorWebApp = true; }); } public override void ConfigureServices(ServiceConfigurationContext context) { var hostingEnvironment = context.Services.GetHostingEnvironment(); var configuration = context.Services.GetConfiguration(); // Add services to the container. context.Services.AddRazorComponents() .AddInteractiveServerComponents() .AddInteractiveWebAssemblyComponents(); if (!configuration.GetValue<bool>("App:DisablePII")) { Microsoft.IdentityModel.Logging.IdentityModelEventSource.ShowPII = true; Microsoft.IdentityModel.Logging.IdentityModelEventSource.LogCompleteSecurityArtifact = true; } if (!configuration.GetValue<bool>("AuthServer:RequireHttpsMetadata")) { Configure<OpenIddictServerAspNetCoreOptions>(options => { options.DisableTransportSecurityRequirement = true; }); } context.Services.AddDevExpressBlazor(); context.Services.AddSyncfusionBlazor(); Configure<AbpStudioClientOptions>(options => { options.IsLinkEnabled = false; //options.StudioUrl = ""; }); ConfigureAuthentication(context); ConfigureUrls(configuration); ConfigureBundles(); ConfigureImpersonation(context, configuration); //ConfigureAutoMapper(context); ConfigureVirtualFileSystem(hostingEnvironment); ConfigureSwaggerServices(context.Services); //启用跨域 //ConfigureCors(context, configuration); ConfigureExternalProviders(context, configuration); ConfigureAutoApiControllers(); ConfigureBlazorise(context); ConfigureRouter(context); ConfigureMenu(context); ConfigureCookieConsent(context); ConfigureTheme(); ConfigureOllama(context); Configure<AbpToolbarOptions>(options => { options.Contributors.Add(new DoctorAIToolbarContributor()); // options.Contributors.Add(new TGAIToolbarContributor()); }); } private void ConfigureOllama(ServiceConfigurationContext context) { McAITools mcAITools = new McAITools(); //9.3 IChatClient client = new OllamaApiClient( "http://172.20.1.57:11434/", "qwq:32b"); client = ChatClientBuilderChatClientExtensions .AsBuilder(client) .UseFunctionInvocation() .ConfigureOptions(opt => { opt.Tools = [AIFunctionFactory.Create(mcAITools.GetMd)]; }) .Build(); context.Services.AddDevExpressBlazor(); context.Services.AddSingleton(client); context.Services.AddDevExpressAI(); } private void ConfigureCookieConsent(ServiceConfigurationContext context) { context.Services.AddAbpCookieConsent(options => { options.IsEnabled = true; options.CookiePolicyUrl = "/CookiePolicy"; options.PrivacyPolicyUrl = "/PrivacyPolicy"; }); } private void ConfigureTheme() { Configure<LeptonXThemeOptions>(options => { options.DefaultStyle = LeptonXStyleNames.System; }); Configure<LeptonXThemeMvcOptions>(options => { options.ApplicationLayout = LeptonXMvcLayouts.SideMenu; }); Configure<LeptonXThemeBlazorOptions>(options => { options.Layout = LeptonXBlazorLayouts.SideMenu; }); } private void ConfigureAuthentication(ServiceConfigurationContext context) { context.Services.ForwardIdentityAuthenticationForBearer(OpenIddictValidationAspNetCoreDefaults.AuthenticationScheme); context.Services.Configure<AbpClaimsPrincipalFactoryOptions>(options => { options.IsDynamicClaimsEnabled = true; }); } private void ConfigureUrls(IConfiguration configuration) { Configure<AppUrlOptions>(options => { options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"]; options.RedirectAllowedUrls.AddRange(configuration["App:RedirectAllowedUrls"]?.Split(',') ?? Array.Empty<string>()); }); } private void ConfigureBundles() { Configure<AbpBundlingOptions>(options => { options.Parameters.InteractiveAuto = true; // MVC UI options.StyleBundles.Configure( LeptonXThemeBundles.Styles.Global, bundle => { bundle.AddFiles("/global-styles.css"); } ); options.ScriptBundles.Configure( LeptonXThemeBundles.Scripts.Global, bundle => { bundle.AddFiles("/global-scripts.js"); } ); // Blazor UI options.StyleBundles.Configure( BlazorLeptonXThemeBundles.Styles.Global, bundle => { bundle.AddFiles("/global-styles.css"); } ); }); Configure<AbpBundlingOptions>(options => { var globalStyles = options.StyleBundles.Get(BlazorWebAssemblyStandardBundles.Styles.Global); globalStyles.AddContributors(typeof(TechGeniusStyleBundleContributor)); var globalScripts = options.ScriptBundles.Get(BlazorWebAssemblyStandardBundles.Scripts.Global); globalScripts.AddContributors(typeof(TechGeniusScriptBundleContributor)); options.Parameters["LeptonXTheme.Layout"] = "side-menu"; // side-menu or top-menu }); } private void ConfigureImpersonation(ServiceConfigurationContext context, IConfiguration configuration) { context.Services.Configure<SaasHostBlazorOptions>(options => { options.EnableTenantImpersonation = true; }); context.Services.Configure<AbpIdentityProBlazorOptions>(options => { options.EnableUserImpersonation = true; }); context.Services.Configure<AbpAccountOptions>(options => { options.TenantAdminUserName = "admin"; options.ImpersonationTenantPermission = SaasHostPermissions.Tenants.Impersonation; options.ImpersonationUserPermission = IdentityPermissions.Users.Impersonation; }); } private void ConfigureVirtualFileSystem(IWebHostEnvironment hostingEnvironment) { if (hostingEnvironment.IsDevelopment()) { Configure<AbpVirtualFileSystemOptions>(options => { options.FileSets.ReplaceEmbeddedByPhysical<TechGeniusDomainSharedModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}TechGenius.Domain.Shared")); options.FileSets.ReplaceEmbeddedByPhysical<TechGeniusDomainModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}TechGenius.Domain")); options.FileSets.ReplaceEmbeddedByPhysical<TechGeniusApplicationContractsModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}TechGenius.Application.Contracts")); options.FileSets.ReplaceEmbeddedByPhysical<TechGeniusApplicationModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}TechGenius.Application")); options.FileSets.ReplaceEmbeddedByPhysical<TechGeniusBlazorModule>(hostingEnvironment.ContentRootPath); }); } } private void ConfigureSwaggerServices(IServiceCollection services) { services.AddAbpSwaggerGen( options => { options.SwaggerDoc("v1", new OpenApiInfo { Title = "TechGenius API", Version = "v1" }); options.DocInclusionPredicate((docName, description) => true); options.CustomSchemaIds(type => type.FullName); } ); } private void ConfigureExternalProviders(ServiceConfigurationContext context, IConfiguration configuration) { ~~~~ } private void ConfigureBlazorise(ServiceConfigurationContext context) { context.Services .AddBlazorise(options => { // TODO (IMPORTANT): To use Blazorise, you need a license key. Get your license key directly from Blazorise, follow the instructions at https://abp.io/faq#how-to-get-blazorise-license-key options.ProductToken = ""; }) .AddBootstrap5Providers() .AddFontAwesomeIcons(); } private void ConfigureMenu(ServiceConfigurationContext context) { Configure<AbpNavigationOptions>(options => { options.MenuContributors.Add(new TechGeniusMenuContributor(context.Services.GetConfiguration())); }); } private void ConfigureRouter(ServiceConfigurationContext context) { Configure<AbpRouterOptions>(options => { options.AppAssembly = typeof(TechGeniusBlazorModule).Assembly; options.AdditionalAssemblies.Add(typeof(TechGeniusBlazorClientModule).Assembly); }); } private void ConfigureAutoApiControllers() { Configure<AbpAspNetCoreMvcOptions>(options => { options.ConventionalControllers.Create(typeof(TechGeniusApplicationModule).Assembly); }); } private void ConfigureCors(ServiceConfigurationContext context, IConfiguration configuration) { ~~~~ } public override void OnApplicationInitialization(ApplicationInitializationContext context) { var env = context.GetEnvironment(); var app = context.GetApplicationBuilder(); app.Use(async (ctx, next) => { /* Converting to https to be able to include https URLs in `/.well-known/openid-configuration` endpoint. * This should only be done if the request is coming outside of the cluster. */ if (ctx.Request.Headers.ContainsKey("from-ingress")) { ctx.Request.Scheme = "https"; } await next(); }); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseAbpRequestLocalization(); if (!env.IsDevelopment()) { app.UseErrorPage(); app.UseHsts(); } app.UseCorrelationId(); app.MapAbpStaticAssets(); app.UseRouting(); var configuration = context.GetConfiguration(); if (Convert.ToBoolean(configuration["AuthServer:IsOnK8s"])) { app.Use(async (context, next) => { if (context.Request.Path.Value != null && context.Request.Path.Value.StartsWith("/appsettings", StringComparison.OrdinalIgnoreCase) && context.Request.Path.Value.EndsWith(".json", StringComparison.OrdinalIgnoreCase)) { // Set endpoint to null so the static files middleware will handle the request. context.SetEndpoint(null); } await next(context); }); app.UseStaticFilesForPatterns("appsettings*.json"); } app.UseAbpSecurityHeaders(); //app.UseCors(); app.UseAuthentication(); app.UseAbpOpenIddictValidation(); if (MultiTenancyConsts.IsEnabled) { app.UseMultiTenancy(); } app.UseUnitOfWork(); app.UseDynamicClaims(); app.UseAntiforgery(); app.UseAuthorization(); app.UseSwagger(); app.UseAbpSwaggerUI(options => { options.SwaggerEndpoint("/swagger/v1/swagger.json", "TechGenius API"); }); app.UseAuditing(); app.UseAbpSerilogEnrichers(); app.UseConfiguredEndpoints(builder => { builder.MapRazorComponents<App>() .AddInteractiveServerRenderMode() .AddInteractiveWebAssemblyRenderMode() .AddAdditionalAssemblies(builder.ServiceProvider.GetRequiredService<IOptions<AbpRouterOptions>>().Value.AdditionalAssemblies.ToArray()); }); } } -
0
请分享一个项目复现问题.
liming.ma@volosoft.com
-
0
已发送
-
0
我无法build你的项目, 他需要很多包我无法还原.
请注入并检查下这个Options的值
var bundlingOptions = context.ServiceProvider.GetRequiredService<IOptions<AbpBundlingOptions>>().Value; //debug to check bundlingOptions.GlobalAssets