Show Inline BitMap in ASPX Page?

C

coconet

I have an ASP.NET 3.5 web application (VS2008) and have a class that
generates a BitMap. I would like to show this as an image inline on an
existing ASP.NET page (showing as an <img> or an <a> image hyperlink).

Thanks.
 
M

Mark Fitzpatrick

You don't dump the image directly into the page. What you do is create a
second page that has absolutely no HTML content in the designer. Then in
code behind you can create an image and then dump it to the
response.outputstream. Then in your page with the <img> tag, you point the
source for that image to the new page you just created. To the browser it
appears as if that other file is just another image since it's getting back
a valid image.

Keep in mind though, standard bitmap BMP's aren't really browser friendly.
Some browsers don't support them, and the resultant BMPs are often huge when
compared to other formats such as jpg or png.
 
M

Michael Nemtsev

I think the best option is to create IHttpHandler where you will create your
images with your class.

After that you can generate all images in your pages via image handler.

google by "asp.net ihttphanlder image" to find samples
 
C

coconet

The problem with the IHttpHandler is that I cannot install things into
IIS or make changes to script mappings or etc. I have to have a "pure
xcopy" solution. Even if there is a speed penalty, I would like to
have an image-emitting class that creates a JPG that I can just put
into a page from a codebehind.

I am looking around on the web for more ideas, but all input here is
preferred and appreciated. :)

Thanks.
 
W

Walter Wang [MSFT]

Hi,

You should only need to modify your web application's web.config to use an
IHttpHandler.

On the other hand, using some WebForm to output image data is also easy to
achieve, all you need is to correctly set the HTTP header and the
ContentType, please refer to following KBs:

How To Write Binary Files to the Browser Using ASP.NET and Visual C# .NET
(http://support.microsoft.com/kb/306654)

HOW TO: Read and Write BLOB Data by Using ADO.NET Through ASP.NET
(http://support.microsoft.com/kb/326502)


Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top