首页 > 解决方案 > 部署到 IIS 后,Blazor 服务器组件无法路由到基本 URL

问题描述

我们已将 Blazor 服务器应用程序部署到 IIS,当我们浏览时,登录后使用 http://someIp/WebTool URL 获取登录页面,下一个组件将重定向到 http://someIp/Dashboard 但我们需要类似 http:// someIp/WebTool/Dashboard.The Webtool 在我们尝试更改 _Host.cshtml 的 IP 后丢失,但是没有用,任何人都可以让我们知道我们哪里出错了。我们也尝试过 app.UsePathBase("/Webtool"); 在 Startup.cs 中。任何建议都会有所帮助,在此先感谢

 public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            app.UsePathBase("/UpgradeWeb");
            app.UseStaticFiles();
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
               
                app.UseHsts();
            }
             
            app.UseHttpsRedirection();
            app.UseRouting();
            app.UseAuthentication();
            app.UseAuthorization();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapBlazorHub();
                endpoints.MapFallbackToPage("/_Host");
            });
        }
 public void ConfigureServices(IServiceCollection services)
        {
            services.AddRazorPages();
            services.AddServerSideBlazor();
            services.AddScoped<AuthenticationStateProvider, CustomAuthenticationStateProvider>();
            services.Configure<ToolConfig>(Configuration.GetSection("ToolConfig"));
            services.AddScoped<IUserService, UserService>();
            services.AddSingleton<HttpClient>();
            var appSettingSection = Configuration.GetSection("AppSettings");
            services.Configure<ApiKeyDetails>(Configuration.GetSection("ApiKeyDetails"));
            services.Configure<WebAppSettings>(appSettingSection);
            services.AddScoped<InvokeApiHandler>(); 
            services.AddScoped<SessionService>();
            services.AddScoped<DashboardService>();
            services.AddScoped<UpgradeRequestService>();
            services.AddScoped<Information>();
            services.AddScoped<ReportsService>();
            services.AddScoped<MasterConfigurationService>();
            services.AddScoped<UserMappingService>();
            services.AddScoped<RolesService>();
            services.AddScoped<AllReportsService>();
            services.AddScoped<JiraService>();
            services.AddScoped<NotificationService>();
            services.AddBlazoredSessionStorage();
        }

标签: iisblazor-server-side

解决方案


推荐阅读