IAM将ASP.NET Core Razor 页面与Electron NET一起使用
在调试Electron应用程序时,当我使用electronic cli构建它时,它的运行没有错误
>electronize build /target win
并运行它安装的安装程序,该应用程序出现在任务管理器上,但没有窗口我的代码:在启动中
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseMigrationsEndPoint();
}
else
{
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();
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapRazorPages();
});
if (HybridSupport.IsElectronActive)
{
CreateWindow();
}
}
private async void CreateWindow()
{
var window = await Electron.WindowManager.CreateWindowAsync();
window.OnClosed += () => {
Electron.App.Quit();
};
}
并在程序中: public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseElectron(args);
webBuilder.UseStartup<Startup>();
});
最佳答案
当我使用MVC项目而不是 Razor 页面时,其工作正常
关于electron - 在Win10中Electron NET不在生产模式下运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66295241/