Guys I am trying to pass a variable from one page to another. Upon searching I found that either QueryString method is used or Session is used for passing variable. I don't like QueryString method as it displays data in URL which could be modified so I went for sessions.
Now I have added a DataGridView in asp which has a button in each row. Upon clicking this button, a session variable is created having the value of 1st column of the row in which the button was clicked and then it redirects to another page in which I am using this session variable.
Now the problem is, when I was using the Visual Studio debugger, this was working fine and the variable value kept changing according to the button click. But once I uploaded the site to hosting, the variable is created the first time I click the button in DataGridView but when I press the button again in different row, the variable value doesn't change. It remains constant, unless I press F5 in browser on the redirected page, only then the value gets updated.
I think the value gets stored in browser's cache and doesn't change until I force refresh the page. What should I do to solve this problem? is there any other way to pass variable other than the above two mentioned methods?
Code for creating session and redirecting :
GridDataItem item = (GridDataItem)e.Item;
string ticketid = item["ID"].Text;
Session["viewID"] = ticketid;
Response.Redirect("View.aspx");
Code for retrieving session :
String s = Session["viewID"] as String;
I would also like to avoid using cookies, many users have cookies disabled in their browsers so using cookies wont be optimal.