Installation
add BlazorPlus.dll via https://www.nuget.org/packages/BlazorPlus
Or use the default template https://github.com/BlazorPlus/BlazorPlus
Installation server-side :
1 - Startup.cs
in ConfigureServices :
services.AddHttpContextAccessor();
services.AddScoped<BlazorPlus.BlazorSession>();
in app.UseEndpoints : (before Fallback)
endpoints.Map("/_blazorplus_handler", BlazorPlus.BlazorSession.ProcessRequestAsync);
2 - _Host.cshtml
in <head> :
<script src="/_blazorplus_handler?action=script" type="text/javascript"></script>
3 - _Imports.razor
@using BlazorPlus
4 - App.razor
at the front:
<BlazorContainer IsShared="true" />
Now test it in Index.razor:
<button @onclick="ShowHelloWorld">Hello World</button>
@code{
void ShowHelloWorld()
{
BlazorSession.Current.Alert("Greeting", "Hello World");
}
}
Installation WebAssembly
1 - Program.cs
BlazorPlus.BlazorSession.InitForWasm(builder.Services);
builder.Services.AddScoped<BlazorPlus.BlazorSession>();
2 - _Imports.razor
@using BlazorPlus
3 - MainLayout.razor
at the front:
@inject BlazorSession bses
<BlazorContainer IsShared="true"/>
Now test it in Index.razor:
<button @onclick="ShowHelloWorld">Hello World</button>
@code{
void ShowHelloWorld()
{
BlazorSession.Current.Alert("Greeting", "Hello World");
}
}