Thanks, but sadly that is not working. I think the issue is staticfiles. The blazor.server.js file cant be found if i navigate to https://localhost:5001/_framework/blazor.server.js
But, in the post you linked he is mapping a fallback to a controller Blazor with action home. I dont know why he would do that. Cant see any controller named blazor in his example either
I have added the following right into (ill move it to custom startups later when its working).
ApplicationBuilderExtensions.cs At the end of UseNopStaticFiles i added application.UseStaticFiles();
and inside UseNopEndpoints: public static void UseNopEndpoints(this IApplicationBuilder application) { //Execute the endpoint selected by the routing middleware application.UseEndpoints(endpoints => { //register all routes EngineContext.Current.Resolve<IRoutePublisher>().RegisterRoutes(endpoints); endpoints.MapBlazorHub(); }); }
And in ServiceCollectionExtensions.cs i added Below this: services.AddRazorPages(); I added services.AddServerSideBlazor();
In home.cshtml i added: @(await Html.RenderComponentAsync<Nop.Web.Views.Shared.Component.TestComponent>(RenderMode.ServerPrerendered))
In _ViewImports.cshtml i added: @using System.Net.Http @using Microsoft.AspNetCore.Authorization @using Microsoft.AspNetCore.Components.Authorization @using Microsoft.AspNetCore.Components.Forms @using Microsoft.AspNetCore.Components.Routing @using Microsoft.AspNetCore.Components.Web @using Microsoft.JSInterop @using System.IO
In _Root.cshtml i added: @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
and inside <head>
<base href="/" />
and below </html> i added <!script src="_framework/blazor.server.js"></!script>
In TestComponent.razor i added: <div class="card-header">
Blazor is a SPA framework. Are you looking at totally replacing the front end for customers and you the NOP web api? Or are you just wanting to use Blazor as components?
If it is just Blazor as components on a page, then I have a solution that I can share with you that works with MVC and should work with NOP.
Let me try and will get back to you. The trick is starting up the Blazor WASM rendering engine. I am not sure if it can be done from the pluging as it is part of the WebApplicationBuilder.
Let me try and will get back to you. The trick is starting up the Blazor WASM rendering engine. I am not sure if it can be done from the pluging as it is part of the WebApplicationBuilder.