Skip to content

FlashMessage provides easy cross request notifications for ASP.NET MVC based on Twitter Bootstrap alerts.

License

Notifications You must be signed in to change notification settings

MicheleRoma/FlashMessage

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FlashMessage

NuGet version

FlashMessage provides easy cross request notifications for ASP.NET MVC based on Twitter Bootstrap. It solves the problem with flashing the user a notification or message when using the Post/Redirect/Get pattern and RedirectToAction() method.

Usage

Install the FlashMessage NuGet package and import the Vereyon.Web namespace where you need it.

Rendering flash messages

Typically you want to render all queued flash messages in your Layout Razor template using the following code:

@Html.RenderFlashMessages()

Queuing flash messages

Queuing a confirmation message for display on the next request after for example user login is done as follows:

// User successfully logged in
FlashMessage.Confirmation("You have been logged in as: {0}", user.Name);
return RedirectToLocal(returnUrl);

Different types of messages can be scheduled using different static methods on the FlashMessage object:

FlashMessage.Info("Your informational message");
FlashMessage.Confirmation("Your confirmation message");
FlashMessage.Warning("Your warning message");
FlashMessage.Danger("Your danger alert");
FlashMessage.Danger("Message title", "Your danger alert");

Advanced options

Using the FlashMessage.Queue() method advanced options are available:

FlashMessage.Queue(string.Format("You have been logged in as: {0}", user.Name), "Title", FlashMessageType.Confirmation, false);

The FlashMessage class allows you to queue messages anywhere in your code where a HttpContext is available and the response has not yet been sent out. You can thus also use FlashMessage outside your MVC actions or with WebForms applications.

Tests

Got tests? Yes, see the tests project. It uses xUnit.

More information

License

MIT X11

About

FlashMessage provides easy cross request notifications for ASP.NET MVC based on Twitter Bootstrap alerts.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%