Click here to Skip to main content
15,899,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(Server.MapPath("a.bmp"));

                bmp.Save(Page.Response.OutputStream,System.Drawing.Imaging.ImageFormat.Gif);
                

                Page.Response.ContentType = "image/jpeg";

The Problem I am facing is that the image is shown at the entire page and nothing else can be seen.
I want it in
<img src="PaTH"\>

Please help

Edit: OP's answer moved here
I dont know anything abt HTTP Handlers
Please make a code for me using HTTP Handlers for the code

C#
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(Server.MapPath("a.bmp"));
      bmp.Save(Page.Response.OutputStream,System.Drawing.Imaging.ImageFormat.Gif
      Page.Response.ContentType = "image/jpeg";
Posted
Updated 14-Apr-12 23:41pm
v3
Comments
Nelek 15-Apr-12 5:45am    
If you need to add some information, please use "improve question" to add it.
If you want to directly speak with someone who answered you, then please use the "have a question or comment?" button at the answer.

On the other hand... People here help solving problems, not making full code for you. So please first investigate a bit and try it in your own.

1 solution

There are a variety of ways to do this: the simplest is to output the HTML img tag code directly:
C#
Response.Write(@"<img src=""http://www.MyDomain.com/MyImage.jpg"" />");

Unfortunately, that means that the folder the image is in must be accessible to all users - or the image can't be read.
Another solution is to embed an ashx page reference in the img tag, and load the image in that - it's a small change to existing code: A generic Image-From-DB class for ASP.NET[^] This way, the images are only available via your site - not generally.

[edit]Domain and image name made generic - OriginalGriff[/edit]
 
Share this answer
 
v2
Comments
ankitpsaraogi 15-Apr-12 12:27pm    
Thanks I have used httphandler

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900