How to fix this end point problem in blazor web server app?

gciraman2024

Member
Joined
May 19, 2024
Messages
12
Programming Experience
3-5
Hi Team

I have a web server in Blazor, but maybe my application is not registered well according to the project structure. The issue is as below exception,

  • InvalidOperationException: Cannot find the fallback endpoint specified by route values: { page: /_Host, area: }.​

    • Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.DynamicPageEndpointMatcherPolicy.ApplyAsync(HttpContext httpContext, CandidateSet candidates)​

    • Microsoft.AspNetCore.Routing.Matching.DfaMatcher.SelectEndpointWithPoliciesAsync(HttpContext httpContext, IEndpointSelectorPolicy[] policies, CandidateSet candidateSet)​

    • Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.<Invoke>g__AwaitMatch|10_1(EndpointRoutingMiddleware middleware, HttpContext httpContext, Task matchTask)​

    • Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)​

    • Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)​


Project Name=>Pages=>_Host.cshtml, MainScreen.razor
=>Components=>AddDeviceModal.razor, App.razor,Routes.razor,_Imports.razor
=>Models=>Device.cs, Operation.cs
=>Shared=>MainLayout.razor


//Program.cs
32:
using OperationApplication.Components;
using Blazored.Modal;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();
builder.Services.AddBlazoredModal();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
    app.UseExceptionHandler("/Error");
    app.UseHsts();
}

app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();

app.UseAuthorization();

app.MapBlazorHub();
app.MapFallbackToPage("/_Host"); // this line throws an exception as invalida invokation

app.Run();
 
Back
Top Bottom