Last post Jan 16, 2009 07:17 AM by Careed
Jan 15, 2009 03:00 AM|MaunoMato|LINK
I have done this asp.net application, but there's a small error. I have httphandler that overlays error image to any image that is called with a parameter.
It works on my development server, but not in my production server.
Production server is Windows server 2003 with IIS 6 and ASP.NET 2.0
So http://localhost:63553/Images/User.png?Error=1 works,
but http://www.mywebappserver.com/Images/User.png?Error=1 doesn't.
Later shows just the image without error image on top of it.
Here's my handler file:
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class ImageHandler : IHttpHandler, IRequiresSessionState
public void ProcessRequest(HttpContext context)
Bitmap Bm = new Bitmap(context.Server.MapPath(context.Request.Path));
Graphics G = Graphics.FromImage(Bm);
if (context.Request.QueryString["Mode"] == "Error")
string PhysicalModeFile = context.Server.MapPath("~/Images/Error.png");
Bitmap OverLay = new Bitmap(PhysicalModeFile);
G.DrawImageUnscaledAndClipped(OverLay, new Rectangle(new Point(Bm.Width - OverLay.Width, Bm.Height - OverLay.Height), OverLay.Size));
MemoryStream MStr = new MemoryStream();
MStr.Position = 0;
public bool IsReusable
And my web.config:
<add verb="*" path="*" type="MyWebApp.ImageHandler, MyWebApp"/>
Jan 15, 2009 07:52 AM|Careed|LINK
When you're working in your development environment, it appears that you're using the development web server built into Visual Studio. Thus, all of your code will work.
Now, you have moved your application to the IIS environment, where you have to configure IIS to work with all of your files. So, for the handler to process your PNG files, the PNG file has to be processed by ASP.NET. To do this, you need to add the .png
file to the Mappings tab in the Application Configuration dialog accessible from the Home or Virtual Directory tab in the IIS Properties dialog. You should use the same mapping configuration as .aspx.
Jan 16, 2009 06:43 AM|MaunoMato|LINK
There isn't way to get this working for all file types at once? Something what path="*" should do.
So if I have jpeg, bmp, gif, tiff, etc. files, I must add mapping for each of those separtly.
Jan 16, 2009 07:17 AM|Careed|LINK
You are correct. You have to have each file (MIME) type configured in IIS to use ASP.NET so that it can be processed by your handler. You can, of course, restrict the various types by only using maybe one or two image formats.
For more information, look at this: