We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Why Retrieving Barcode Image From MemoryStream in aspx file destroyed my sessions?


I've problem using AsposeBarcode to retrieve barcode image from memory stream.

I create 1 aspx page called GenerateBarcode.aspx which receive querystring "code". Then this page is generating barcode image on the fly using httphandler.

Below is the code :

protected void Page_Load(object sender, EventArgs e)


if (Request.QueryString["code"] != null)



BarCodeBuilder bb = new BarCodeBuilder();

bb.CodeText = decodeString(Request.QueryString["code"].ToString());

bb.ImageWidth = 255;

bb.ImageHeight = 50;

bb.BarHeight = 40;

bb.CaptionBelow.Visible = false;

bb.CodeLocation = Aspose.BarCode.CodeLocation.None;

bb.ImageUnit = System.Drawing.GraphicsUnit.Pixel;

bb.SymbologyType = Symbology.Code128;

System.IO.MemoryStream mStream = new System.IO.MemoryStream();

bb.BarCodeImage.Save(mStream, System.Drawing.Imaging.ImageFormat.Jpeg);

if (BA2.Services.Caching.Get(bb.CodeText) == null)


BA2.Services.Caching.Add(bb.CodeText, mStream);



System.IO.MemoryStream cachedStream = (System.IO.MemoryStream)BA2.Services.Caching.Get(bb.CodeText);

Response.ContentType = "image/jpeg";





Response.ContentType = "text/html";


Need a valid Batch ID




I tried to implement this in my dotnetnuke module. In my module, i called this page using

When i executed the dnn, my image doesn't show up, it only shows "X" image indicating the image isn't loaded successfully. Then I also notice that this caused all of my session suddenly destroyed.

Anyone know how is this happen?



Thanks for considering Aspose.

We will test this scenario with DNN and will post the feedback shortly.