Files
Electron.NET/docs/GettingStarted/ASP.Net.md
softworkz 0a0e26a9dd Add docs
2025-10-15 12:54:08 +02:00

1.5 KiB

🛠 Requirements to Run

Our API uses .NET 6/8, so our

Also you should have installed:

👩‍🏫 Usage with ASP.Net

  • Create a new ASP.Net Core project
  • Install the following two nuget packages:
PM> Install-Package ElectronNET.Core

PM> Install-Package ElectronNET.Core.AspNet

Enable Electron.NET on Startup

To do so, use the UseElectron extension method on a WebApplicationBuilder, an IWebHostBuilder or any descendants.

Note

New in Electron.NET Core is that you provide a callback method as an argument to UseElectron(), which ensures that you get to know the right moment to set up your application UI.

Program.cs

using ElectronNET.API;
using ElectronNET.API.Entities;

    public static void Main(string[] args)
    {
        WebHost.CreateDefaultBuilder(args)
            .UseElectron(args, ElectronAppReady)
            .UseStartup<Startup>()
            .Build()
            .Run();
    }

   public static async Task ElectronAppReady()
    {
        var browserWindow = await Electron.WindowManager.CreateWindowAsync(
            new BrowserWindowOptions { Show = false });

        browserWindow.OnReadyToShow += () => browserWindow.Show();
    }