Skip to content

Minimalist flash message system for ASP.NET MVC Core.

Notifications You must be signed in to change notification settings

martinto/core-flash

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Core.Flash2 NuGet

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

Install Core.Flash2

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.

Meet Core.Flash2

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>&copy; 2017</p>
    </footer>
</div>

Core.Flash2 uses Bootstrap Alerts.

Sample

_Copyright © 2017 Lurumad Contributors

About

Minimalist flash message system for ASP.NET MVC Core.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%