I am working on a project, i have on ashx handler file,
I want to make some ViewState data in my ashx file and then check it on .cs file
How can i achieve this as i can't access ViewState object in my ashx file
No you cannot access the data of page in Ashx file because it handler and get executed when the request to page take place.
Instead of viewstate you can make use of Session boject liek this
public class Handler : IHttpHandler, System.Web.SessionState.IRequiresSessionState
{
public void ProcessRequest(HttpContext context)
{
context.Session["sessionvariable"] = "value";
}
}
or to just readonly acces to session object
public class Handler : IHttpHandler, IReadOnlySessionState
{
public bool IsReusable { get { return true; } }
public void ProcessRequest(HttpContext ctx)
{
ctx.Response.Write(ctx.Session["fred"]);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With