Question

How would you implement a user message stack in ASP.Net MVC? (you set messages for the user in any place inside your app. and they are shown as hints of your app to the user anywhere inside the app)

I want to hear your ideas and thoughts. How would you do it?

e.g.:

User stack message example

Was it helpful?

Solution

I would use a combination of session and cookies to regulate the messages presented to the user. By doing this I would reduce the annoyance factor for the users and show them messages the least amount of times possible.

In MVC I would use a Partial View, that you can render on all your pages, and have it's behavior be independent of the site. Or have it be context aware.

Edit:

As mentioned in the comments, it can also be a good idea to store user dependent information in a database. This can allow for messages to be displayed to authenticated / known users. My original answer was mostly targeted at anonymous users.

For authenticated users, you could have a message table, with a read / not read bit, or even a simply push table where you push messages and delete them from the table once the user has seen it.

You may require a 2 part system. One for the messages displayed to anonymous users. The second part would be for authenticated users about their personal profile/events related to them or the site.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top