Home > Enterprise >  Blazor page routing integration into existing razor page app
Blazor page routing integration into existing razor page app

Time:02-22

I followed the documentation here as best as I could. _host app.razor

enter image description here

the test page is this enter image description here

I've updated the startup blazorHub() and MapFallbackToPage() endpoints

enter image description here

If I browser to existing razor Page ClientDashboard.cshtml and have it load the component the blazor page will load and function. So I know my blazor.js is loading correctly

@(await @Html.RenderComponentAsync<Components.ClientDashboard.ClientManagement>(RenderMode.Server, new{clientId = @Model.ClientID}))

But I'm not wanting to bypass this and just actual routing to navigate to my blazor pages localhost.com/ClientDashboard/42 for example.

But I'm currently getting page error when trying to browse to https://localhost:5001/TestRouting page

enter image description here enter image description here

I'm unsure what I'm missing or how to debug this and guidance would be appreciated!

Update I tried PMC suggestion but got different error page came up blank with this error in browser tools

enter image description here

enter image description here

Update 2

Moved all files into the Pages directory just in case there was an issue with the locations. Also tried a few versions of the host.cshtml

enter image description here

still, get null reference exception either directly on the page or in the console of the browser.

Referenced PMC enter image description here

CodePudding user response:

Try change

<Router AppAssembly="typeof(App).Assembly">

to this in your App.Razor file

<Router AppAssembly="typeof(Program).Assembly">

I followed this enter image description here

  • Related