can i pass my generic list to my generic handler through HttpContext?
protected void BtnExportCSV_Click(object sender, EventArgs e)
{
List<Product> products = BLL.GetProducts();
HttpContext.Current.Items["products"] = products;
Response.Redirect("ToCsvHelper.ashx", false);
}
it’s null when it gets to handler. So is the better way to regenerate the products list within the generic handler somehow? what if i want it usable for not just a products list?
HttpContext lifetime is single request, Redirect does client side redirect and as result you have 2 requests.
You can use session state to pass such data, or view state, or query every time.
Static data (not per-user) can be shared via application level cache (or static members, also it is not a good idea).