I am setting a session value in the Handler page and want to use that in other page, when I access the session value in other page I get the error saying Object reference not set to an instance of an object.
string ad=Session["StackOverflow"].ToString();
How to access the session value in c# .aspx page
public class Upload : IHttpHandler, IRequiresSessionState{
public void ProcessRequest (HttpContext context) {
context.Session.Add("StackOverflow",filename);
}}
What you have there should work except it is worth noting that you need to include an implementation of the IRequiresSessionState interface.
EDIT: OP edited question after post
In order to access the variable in your other page be sure to implement IRequiresSessionState on that page too. If you fail to do this you will not have access to the session variables.
EDIT: Futher info requested by OP
In order to access the session variable on your aspx page do the following:
Now to add this into your onclick function in the html/aspx page you do this