-
Notifications
You must be signed in to change notification settings - Fork 0
ASP.Net
ASP.NET Core remains the recommended approach for complex web applications with ElectronNET.Core, providing all the benefits of the ASP.NET ecosystem along with enhanced Electron integration.
See System Requirements.
Create a new ASP.NET Core Web App in Visual Studio:
dotnet new webapp -n MyElectronWebApp
cd MyElectronWebAppPM> Install-Package ElectronNET.Core
PM> Install-Package ElectronNET.Core.AspNetNote
ElectronNET.Core.AspNet provides ASP.NET-specific runtime components and should be used alongside ElectronNET.Core.
Update your Program.cs to enable Electron.NET:
using ElectronNET.API;
using ElectronNET.API.Entities;
public class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorPages();
// Add this line to enable Electron.NET:
builder.UseElectron(args, ElectronAppReady);
var app = builder.Build();
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
}
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.MapRazorPages();
app.Run();
}
public static async Task ElectronAppReady()
{
var browserWindow = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions { Show = false });
browserWindow.OnReadyToShow += () => browserWindow.Show();
}
}If you want to launch a specific URL, you can retrieve the actual ASP.NET port from the new ElectronNetRuntime static class, for example:
await browserWindow.WebContents
.LoadURLAsync($"http://localhost:{ElectronNetRuntime.AspNetWebPort}/mypage.html");For projects using the traditional Startup.cs pattern, please see "Traditional ASP.NET Core" in the Migration Guide.
- Debugging - Learn about ASP.NET debugging features
- Package Building - Create distributable packages
- Startup Methods - Understanding launch scenarios
✅ Full Web Stack - Use MVC, Razor Pages, Blazor, and all ASP.NET features
✅ Hot Reload - Edit ASP.NET code and see changes instantly
✅ Rich Ecosystem - Access to thousands of ASP.NET packages
✅ Modern Development - Latest C# features and ASP.NET patterns
✅ Scalable Architecture - Build complex, maintainable applications
Want to contribute to this documentation? Please fork and create a PR! The Wiki is autogenerated from the /docs content in the repository.