Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6235255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:38:19+00:00 2026-05-24T10:38:19+00:00

I’ve built a notification system for an ASP.NET MVC3 site I’ve been working on

  • 0

I’ve built a notification system for an ASP.NET MVC3 site I’ve been working on that lets the user know that various actions they performed happened successfully (a “pat on the back” message). The solution works pretty well, but I have one issue that I would love to solve, but I can’t seem to wrap my head around how to do so.

In a controller, I have the following example action methods:

<HttpGet()>
Public Function Edit(id As Guid) As ActionResult
    Return View(GetMyViewModel(id))
End Function

<HttpPost()>
Public Function Edit(...) As ActionResult
    ' Save updated ... information

    Me.TempData("UserMessage") = "Data Saved! You are truly an awesome user!"

    ' PRG back to Edit
    Return RedirectToAction("Edit")
End Function

Then in my view (razor layout) I have code that looks for the existence of the "UserMessage" key in the TempData collection, and if it exists I build out some JavaScript to present a growl-like notification for the user:

/* This only exists when we have something to show */
$(function () {
    showNotification([the message from TempData]); 
});

The growl-like message then either goes away over time or the user can click on the message to dismiss it.

So far so good, everything is working as expected. User POSTs to Edit, they are RPGed back to Edit, the growl-like “Data Saved! You are truly an awesome user!” message is shown and dismissed.

If the user then navigates to another page and then hits the browser’s back button, the browser then digs into its cache, resulting in the browser executing the same javascript, showing the user the same “Data Saved! You are truly an awesome user!” message again. This confuses the heck out of the user thinking that, by clicking the back button, they just did something that caused yet another save (or whatever the message was).

I’m looking for a way, that once the notification is shown once, I can somehow prevent the notification from ever showing back up — basically making it a “one time shot” message. Things I have thought about are:

  • including a Guid with every message, and using localStorage to store a list of shown message ids, and only if the message being requested doesn’t already exist in the list of shown messages, show it.
    • I’ve thought of using a Cookie in the same way, but cringed at the idea that the cookie is needlessly blasted back to the server for future requests, plus the content of the cookie would need to be carefully considered and probably per-message anyhow.
  • Instead of returning a message from the action method, return a Guid instead that points to a message in a database. Then on page load, AJAX back to the server to get that message. Once a message is got, it is deleted from the database, subsequent requests for that same message are handled by returning no message.
  • include a Guid with every message, and before showing the message, AJAX back to the server to see if the message has already been shown. Once the message is shown, AJAX back to the server to log that the message has been shown.

These all seem pretty untenable to me, but I could be convinced otherwise if someone wants to argue support for one of these.

Things I have tried:

  • After the message is dismissed removing all traces of the DOM element.
  • When the message is shown, set a jQuery .data() property on the message’s DOM element to indicate that the message was shown, then before showing the message, make sure the .data() field doesn’t exist.

These don’t work because the browser caches pages at a point in time where both of these DOM changes happen afterwards.

Basically, I need a mechanism that my javascript can check to see if it really needs to show this given message, and if it does, show it, but then mark the message as shown so that if it is requested to be shown again, it doesn’t. Any suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T10:38:21+00:00Added an answer on May 24, 2026 at 10:38 am

    You could set a cookie to store the state of the message being shown, and check for the presence of the cookie when you attempt to show the message. If the cookie is there, you don’t, and if it isn’t, you do.
    Seems like the logic for that would be pretty simple, as opposed to tracking GUIDs 🙂

    // pseudocode
    FUNCTION ShowMessage(args)
        // if the cookie is here, don't show the message
        IF StatusCookieIsPresent THEN RETURN
    
        // if the cookie isn't here, this is the first time showing the message
        ShowStatusMessage()
    
        // we showed the message, so set the cookie to make sure we don't
        // do it twice
        SetStatusCookie()
    END FUNCTION
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am doing a simple coin flipping experiment for class that involves flipping a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.