Blazor ElectronNET应用程序无法加载localhost ERR_CONNECTION_REFUSED



我有一个使用ElectronNET和Blazor为windows和osx构建的应用程序。在我的windows机器上一切都很好,但当我试图在osx上运行软件时,我得到了一个空白的白色屏幕,调试终端显示

"(节点:14402(电子:无法加载URL:http://localhost:8002/带有错误:ERR_CONNECTION_REFUSED";

如果我转到菜单栏并点击刷新页面加载,我会得到另一条消息

"警告:Microsoft.AspNetCore.HttpsPolicy.HttpsDirectionMiddleware[3]无法确定重定向的https端口">

我试过清理我的项目,删除bin和obj文件夹,删除.vs文件夹,关闭防火墙,配置chrome,检查代理等。到目前为止,一切都不起作用,我不知道该怎么办了。

using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using ElectronNET.API;
using ElectronNET.API.Entities;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();
builder.Services.AddServerSideBlazor().AddCircuitOptions(options => { options.DetailedErrors = true; });
builder.Services.AddDevExpressBlazor();
builder.Services.AddElectron();
builder.Services.Configure<DevExpress.Blazor.Configuration.GlobalOptions>(options => {
options.BootstrapVersion = DevExpress.Blazor.BootstrapVersion.v5;
});
builder.WebHost.UseWebRoot("wwwroot");
builder.WebHost.UseStaticWebAssets();
builder.WebHost.UseElectron(args);

var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
var browserWindowOptions = new BrowserWindowOptions
{
AutoHideMenuBar = true
};
var browserWindow = await Electron.WindowManager.CreateWindowAsync(browserWindowOptions);
app.MapBlazorHub();
app.MapFallbackToPage("/_Host");
app.Run();

更改此行

var browserWindow = await Electron.WindowManager.CreateWindowAsync(browserWindowOptions);

到这个

async void CreateWindow()
{
var window = await Electron.WindowManager.CreateWindowAsync(browserWindowOptions);
window.OnClosed += () => {
Electron.App.Quit();
};
}

修复问题

相关内容

  • 没有找到相关文章

最新更新