Skip to content

Illustrates a method of displaying Bootstrap Alert messages in ASP.NET Core applications.

Notifications You must be signed in to change notification settings

MattHoneycutt/HeroicSamples.BootstrapAlerts

Repository files navigation

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!");
}

About

Illustrates a method of displaying Bootstrap Alert messages in ASP.NET Core applications.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published