Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Host Blazor component in Avalonia

$
0
0

I'm trying to host a Blazor component in an Avalonia application using a WebView.

I have a Blazor project with the following class:

public class ServerManager{    private static WebApplication? _host;    public static void RunServer(string[] args)    {        var builder = WebApplication.CreateBuilder(args);        builder.Services.AddRazorPages();        builder.Services.AddServerSideBlazor();        builder.Services.AddSingleton<WeatherForecastService>();        _host = builder.Build();        if (_host.Environment.IsDevelopment())        {            _host.UseDeveloperExceptionPage();        }        else        {            _host.UseExceptionHandler("/Error");            _host.UseHsts();        }        _host.UseHttpsRedirection();        _host.UseStaticFiles();        _host.UseRouting();        _host.MapBlazorHub();        _host.MapFallbackToPage("/_Host");        _host.Start();    }    public static void StopServer()    {        _host?.DisposeAsync();    }

The main application has a reference to the Blazor project and calls RunServer on startupand StopServer on exit. The WebView address is set to https://localhost:7012.

This approach worked fine in WPF but it seems that the server is not correctly started in Avalonia. What am I missing?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>