i want to make asp.net page return image to the browser here is the code
protected void Page_PreRender(object sender, EventArgs e)
{
Response.Clear();
string iName = Request.QueryString.Get("ImageName") ;
Bitmap bmp = new Bitmap(Server.MapPath("a.png"));
Response.ContentType = "image/png";
bmp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Png);
bmp.Dispose();
Response.End();
}
i works fine off line i mean when running it in visual studio but when running in godady hosting environment it gives this error
A generic error occurred in GDI+.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[ExternalException (0x80004005): A generic error occurred in GDI+.]
System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams) +471002
System.Drawing.Image.Save(Stream stream, ImageFormat format) +36
PageReturnImageDeals.MyImage.Page_PreRender(Object sender, EventArgs e) +191
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
System.Web.UI.Control.OnPreRender(EventArgs e) +92
System.Web.UI.Control.PreRenderRecursiveInternal() +83
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +974
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18055