Blazor服务器组件在部署到IIS后无法路由到基本URL
我们已经将Blazor服务器应用程序部署到IIS,当我们浏览时,使用http://someIp/WebTool 登录后的URL下一个组件将重定向到http://someIp/Dashboard 但我们需要像这样的东西http://someIp/WebTool/Dashboard.The 我们尝试在_Host.cshtml中更改IP后,Webtool丢失,但没有任何用处 谁能告诉我们哪里出了问题。我们也试过了 和app.UsePathBase(“/Webtool”);在Startup.cs中。任何建议都会有帮助,提前谢谢Blazor服务器组件在部署到IIS后无法路由到基本URL,iis,blazor-server-side,Iis,Blazor Server Side,我们已经将Blazor服务器应用程序部署到IIS,当我们浏览时,使用http://someIp/WebTool 登录后的URL下一个组件将重定向到http://someIp/Dashboard 但我们需要像这样的东西http://someIp/WebTool/Dashboard.The 我们尝试在_Host.cshtml中更改IP后,Webtool丢失,但没有任何用处 谁能告诉我们哪里出了问题。我们也试过了 和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();
}
public void配置(IApplicationBuilder应用程序,IWebHostEnvironment环境)
{
app.UsePathBase(“/UpgradeWeb”);
app.UseStaticFiles();
if(env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
其他的
{
app.UseExceptionHandler(“/Error”);
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(端点=>
{
endpoints.MapBlazorHub();
endpoints.MapFallbackToPage(“/_主机”);
});
}
public void配置服务(IServiceCollection服务)
{
services.AddRazorPages();
AddServerSideBlazor();
services.addScope();
services.Configure(Configuration.GetSection(“ToolConfig”);
services.addScope();
services.AddSingleton();
var appSettingSection=Configuration.GetSection(“AppSettings”);
services.Configure(Configuration.GetSection(“ApiKeyDetails”);
服务。配置(应用设置部分);
services.addScope();
services.addScope();
services.addScope();
services.addScope();
services.addScope();
services.addScope();
services.addScope();
services.addScope();
services.addScope();
services.addScope();
services.addScope();
services.addScope();
services.AddBlazoredSessionStorage();
}
能否在Startup.cs中显示服务配置?我认为这是身份中的一些配置。嗨@Ricardo添加了startup.cs,请检查您是否使用Preview3。要为Blazor应用程序的基本路径提供配置,标记的href属性设置为Pages/_Host.cshtml文件(Blazor服务器)或wwwroot/index.html文件(Blazor WebAssembly)中的相对根路径: