ASP.NET TempData persists between requests

情到浓时终转凉″ 提交于 2019-11-28 13:26:56

The sole purpose of TempData is to persist until the next request. Stuff you do not want to persist until the next request should go into ViewData, instead.

Realistically, this means that TempData is only safe to use when redirecting. When not redirecting, the "next request" could be anything.

would this be acceptable (removing the error once it has been shown):

<%  If TempData.ContainsKey("ErrorMessage") Then %>
<script> $('div.error-container').show();</script>
<div class="msg-error"><p><%=TempData("ErrorMessage") %></p></div>
<% 
    TempData.Remove("ErrorMessage")
End If
%>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!