Using HttpContext.Current.Items we can access variables from current request
My question is what if the request moves to different thread, can we still access this ?
if Yes, how can we access it ?
I assume it will throw null reference exception ?
I am trying with the below code, but it throws Null Ref Exception
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void BtnClick(object sender, EventArgs e)
{
HttpContext.Current.Items["txtbox1"] = txtbox1.Value;
var t = new Thread(new Threadclas().Datamethod());
t.Start();
}
}
public class Threadclas
{
public void Datamethod()
{
var dat = HttpContext.Current.Items["txtbox1"];
**//how can i access HttpContext here** ?
}
}