Skip to content

Latest commit

 

History

History
33 lines (25 loc) · 921 Bytes

README.md

File metadata and controls

33 lines (25 loc) · 921 Bytes

Heroic Bootstrap Alerts Sample

This sample shows one technique of combining Bootstrap Alerts with ASP.NET Core. You can read more about the technique at try-catch-FAIL.

Examples

You can show an alert off a view result like so:

public IActionResult About()
{
    ViewData["Message"] = "Your application description page.";

    return View().WithSuccess("It worked!", "You were able to view the about page, congrats!");
}

You can also show an alert off a redirect result:

public IActionResult GoHome()
{
    return RedirectToAction("Index").WithWarning("You were redirected!", "The action you hit has bounced you back to Index!");
}

API results are supported, too:

public IActionResult Success()
{
    return Ok(DateTime.UtcNow.ToString()).WithSuccess("Success!", "The API call worked!");
}