if ((context.Session["ImageBytes"]) != null)
{
byte[] image = (byte[])(context.Session["ImageBytes"]);
context.Response.ContentType = "image/JPEG";
context.Response.BinaryWrite(image);
}
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Rahul SinghRank #1,323 · 1.3K reputationPosted Dec 23, 2014, 5:18 PM EST
Based on your explanation, its pretty clear that code is breaking on this line:-
if ((context.Session["ImageBytes"]) != null)
So the problem is your session object itself is null, thus when your are trying to access Session variable with "ImageBytes" it is throwing this exception. Please go through the below link to see why this happens:-
http://forums.asp.net/t/1058823.aspx?context+Session+is+null+in+ProcessRequest
Manish Kumar ChoudharyRank #339 · 7.4K reputationPosted Dec 23, 2014, 6:02 PM EST
byte[] image = (byte[])(context.Session["ImageBytes"]);
Is throwing error session does not contains a value that has been converted to valid byte[]. Check the session for this error correction.
Dhruvi kukadiya18 reputationPosted Dec 23, 2014, 6:16 PM EST
Dhruvi kukadiya18 reputationPosted Dec 23, 2014, 6:18 PM EST