Search code examples
javascriptasp.net-mvcviewdata

How to check whether a ViewData variable expired from javascript or Jquery side


I am retrieving a variable value from ViewData to a javascript variable as follows.

  var selectedList= <%= ViewData["selectedList"] %>;

and by nature ViewData expired after some time. I am looking for a way to check whether this variable has expired from the JavaScript side. I am trying to do this without using a session .


Solution

  • ViewData Value gets expired after page load completes. You can keep ViewData value into Javascript Global variable that you can use for further processing.