Skip to content

lurumad/core-flash

Repository files navigation

Core.Flash NuGet

Minimalistic flash message system for ASP.NET MVC Core to provide contextual feedback messages between actions based on Bootstrap Alerts

Install Core.Flash

You should install Core.Flash:

Install-Package Core.Flash

This command from Package Manager Console will download and install Core.Flash and all required dependencies.

Meet Core.Flash

Register Core.Flash services in your Startup class

public void ConfigureServices(IServiceCollection services)
{
    services
      .AddFlashes()
      .AddMvc();
}

Once you have been register Core.Flash 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(Types.Success, "Flash message system for ASP.NET MVC Core", dismissable: true);
    f.Flash(Types.Danger, "Flash message system for ASP.NET MVC Core", dismissable: false);
    return RedirectToAction("AnotherAction");
}

Add Core.Flash TagHelper to your _ViewImports.cs

@using Core.Flash.Web
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, Core.Flash

Add the TagHelper to your _Layout.cs

<div class="container body-content">
    <div flashes></div>
    @RenderBody()
    <hr />
    <footer>
        <p>&copy; 2017</p>
    </footer>
</div>

Core.Flash uses Bootstrap Alerts.

Sample

_Copyright © 2017 Lurumad Contributors

About

Minimalist flash message system for ASP.NET MVC Core.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •