I would suggest putting data in Session, not TempData, since TempData only stores data until the end of the next request. What happens in your situation is that the user makes a request each time he presses a button, so when you press the second button, TempData is already cleared (or will be cleared at the end of the first request).
You can disable the button after clicking it for the first time, but this may lead to a less reliable solution. Using a session and another AJAX request to clear the data in the session made when the first AJAX request was successfully returned, make sure that you know that the first AJAX request is back and the data in the session can be deleted.
source
share