I have an ASP.NET page where I am rendering some HTML markup which includes a barcode image which is generated by another asp.net page
<div id='divDynamic'>
<h1>Some content</h1>
<img src='barcode.aspx?mode=something' />
</div>
And in the barcode.aspx.cs, I have:
protected void Page_Load(object sender, EventArgs e)
{
Response.CacheControl = "no-cache";
Response.AddHeader("Pragma", "no-cache");
Response.Expires = -1 ;
Response.Buffer = false;
Response.ContentType = "image/JPEG";
MemoryStream ms = new MemoryStream();
System.Drawing.Image objBitmap = GenCode128.Code128Rendering.MakeBarcodeImage(Request.QueryString["mode"] + "", 2,false );
objBitmap.Save(ms ,ImageFormat.Bmp);
Response.BinaryWrite(ms.GetBuffer());
Response.End();
}
I need to use the same functionality in many similar websites. So now I am trying to convert this to a WCF service where the markup for the div "divDynamic" will be generated and will be sent back to the client (an asp.net website). My service has a method of return type string which will return the HTMLMarkup like the following
public string GetUSPSLabelMarkup()
{
StringBuilder strHtml = new StringBuilder();
strHtml.Append("<h1>Some content</h1>");
// How do I have the barcode image here?
return strHtml.ToString();
}
I am wondering how should I have the Image generation part in the above method in my service? I believe Response.BinaryWrite shouldn't work here.