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

blazor wasm works locally but returns 404 when deployed to production after .net 8 migration

$
0
0

I have a blazor wasm client side app recently migrated from .ne6 to 8. App works fine locally but deploying to other env navigates the default notfound page. I have tried multiple solutions after a lot of research but i have not yet found a solutioni recently updated from .net6 to .net8

program.cs

WebAssemblyHostBuilder builder = WebAssemblyHostBuilder.CreateDefault(args);builder.RootComponents.Add<App>("#app");builder.RootComponents.Add<HeadOutlet>("head::after");builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });builder.Services.InjectSharedUI();builder.Services.AddBlazoredLocalStorageAsSingleton();builder.Services.AddMudBlazorSnackbar();builder.Services.AddMudBlazorResizeListener();builder.Services.AddMudBlazorResizeObserver();builder.Services.AddMudBlazorResizeObserverFactory();builder.Services.AddMudPopoverService();builder.Services.AddMudServices();builder.Services.AddCascadingAuthenticationState();builder.Services.AddHttpClient<IApiClientService, ApiClientService>(factory: (client) =>{    UriBuilder uriBuilder = new(builder.Configuration.GetValue<string>("ApiEndpoint"));    client.BaseAddress = uriBuilder.Uri;    string appName = builder.Configuration.GetValue<string?>("ApplicationName") ?? "Online Product Applications";    string appVersion = Extensions.Version(Assembly.GetExecutingAssembly());    return new ApiClientService(client, builder.Configuration, appVersion, appName);});builder.Services.AddMsalAuthentication<RemoteAuthenticationState, RemoteUserAccount>(options =>{    builder.Configuration.Bind("AzureAd", options.ProviderOptions.Authentication);    options.ProviderOptions.DefaultAccessTokenScopes.Add("openid");    options.ProviderOptions.DefaultAccessTokenScopes.Add("https://graph.microsoft.com/openid");    options.ProviderOptions.DefaultAccessTokenScopes.Add("offline_access");    options.ProviderOptions.LoginMode = "redirect";    options.UserOptions.RoleClaim = "roles";    options.ProviderOptions.Cache.StoreAuthStateInCookie = true;});builder.Services.AddSingleton<AppConfiguration>();CultureInfo.DefaultThreadCurrentCulture = Constants.DefaultCultureInfo;CultureInfo.DefaultThreadCurrentUICulture = Constants.DefaultCultureInfo;await builder.Build().RunAsync();

App.razor

<CascadingAuthenticationState><Error><Router AppAssembly="@typeof(App).Assembly"><Found Context="routeData"><AuthorizeRouteView RouteData="@routeData" DefaultLayout="typeof(InternalAppLayout)"><NotAuthorized>                        @if (context.User.Identity is null || context.User.Identity.IsAuthenticated == false)                        {<RedirectToLogin />                        }</NotAuthorized></AuthorizeRouteView><FocusOnNavigate RouteData="@routeData" Selector="h1" /></Found><NotFound><SupplierProductRequest.Admin.Pages.NotFound /></NotFound></Router></Error></CascadingAuthenticationState>

Index.html

<title>Online Product Applications</title><base href="/" /><link rel="icon" type="image/x-ico href="_content/SupplierProductRequest.UI.Shared/favicon.ico"><link href="_content/SupplierProductRequest.UI.Shared/css/custom-loader.css" rel="stylesheet" /><link href="_content/MudBlazor/MudBlazor.min.css" rel="stylesheet" /><link href="_content/SupplierProductRequest.UI.Shared/css/font.css" rel="stylesheet" /><base /><script></script><script src="_framework/blazor.webassembly.js?v=5" async></script><script src="_content/Microsoft.Authentication.WebAssembly.Msal/AuthenticationService.js?v=2" async></script><script src="_content/SupplierProductRequest.UI.Shared/js/shared_ui_methods.js?v=5" defer></script><script src="_content/MudBlazor/MudBlazor.min.js?v=4" defer></script></head><body style="min-height:600px;"><Routes @rendermode="InteractiveServer" /><div id="app"></div><!--  <App @rendermode="@RenderMode.WebAssembly" />--></body></html>

Viewing all articles
Browse latest Browse all 4839

Trending Articles



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