Minimalistic flash message system for ASP.NET MVC Core to provide contextual feedback messages between actions. Forked from lurumad/core-flash and converted to run on netcoreapp2.2
You should install Core.Flash2:
Install-Package Core.Flash2
This command from Package Manager Console will download and install Core.Flash2 and all required dependencies.
Register Core.Flash2 services in your Startup class
public void ConfigureServices(IServiceCollection services)
{
services
.AddFlashes()
.AddMvc();
}
Once you have been register Core.Flash2 services, you can inject the IFlasher interface in your Controllers:
public HomeController(IFlasher f)
{
this.f = f;
}
And call Flash method passing a type and the message:
public IActionResult YourAction()
{
f.Flash("success", "Flash message system for ASP.NET MVC Core");
return RedirectToAction("AnotherAction");
}
Add Core.Flash2 TagHelper to your _ViewImports.cs
@using Core.Flash2.Web
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, Core.Flash2
Add the TagHelper to your _Layout.cs
<div class="container body-content">
<div flashes></div>
@RenderBody()
<hr />
<footer>
<p>© 2017</p>
</footer>
</div>
Core.Flash2 uses Bootstrap Alerts.
_Copyright © 2017 Lurumad Contributors