I have set up a sample blazor.net application as per the Docs. After that I created a new service and hard-coded few data and trying to run the application.
But I'm receiving the following error in the console:
There is no registered service of type
<applicationName>.App.Services.<serviceName>
It seems the new service name need to register some where, how can I register the new service?
When an error occurs, Blazor apps display a light yellow bar at the bottom of the screen: During development, the bar directs you to the browser console, where you can see the exception. In production, the bar notifies the user that an error has occurred and recommends refreshing the browser.
How do you display a validation message specific to a field in a Blazor form? You have to use the <ValidationMessage> tag with the “For” attribute lambda expression pointing to the form field.
The Blazor Server hosting model offers several benefits: Download size is significantly smaller than a Blazor WebAssembly app, and the app loads much faster. -The app takes full advantage of server capabilities, including the use of . NET Core APIs.
Worth noting that for Blazor WebAssembly, there is no Startup class like the one in Blazor Server. In Blazor WebAssembly we can register Services in Program.cs as below:
public static async Task Main(string[] args)
{
var builder = WebAssemblyHostBuilder.CreateDefault(args);
//...other services
builder.Services.AddSingleton<MyNewService>();
builder.RootComponents.Add<App>("app");
await builder.Build().RunAsync();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With