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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Dhruvi kukadiyaPosted Dec 23, 2014, 11:18 PM
Dhruvi kukadiyaPosted Dec 23, 2014, 11:16 PM
Manish Kumar ChoudharyPosted Dec 23, 2014, 11:02 PM
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.
Rahul SinghPosted Dec 23, 2014, 10:18 PM
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