By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,665 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

Image Processing

P: n/a
Hi... I have this simple Page_Load that works as expected, however, the
output in the browser is such that when one tries to right-click to save the
image, it is grabbing the aspx instead of an actual image...

I.e., sending the URL
results in the image in the browser window, but when you right-click Save
Picture as.. you don't get a jpeg, you get an aspx text file.

<%@ Page language="c#" Codebehind="Result.aspx.cs" AutoEventWireup="false"
Inherits="spc.Result" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content=""
Any ideas?

private void Page_Load(object sender, System.EventArgs e)
// Put user code to initialize the page here
string path=
Request.QueryString.GetValues("file").GetValue(0). ToString();
double size =
Convert.ToDouble(Request.QueryString.GetValues("si ze").GetValue(0).ToString(

string fName = path.Substring(0,path.Length-7) + ".jpg";

System.Drawing.Image fullSizeImg;
System.Drawing.Bitmap bmp;
System.Drawing.Graphics g;
fullSizeImg=System.Drawing.Image.FromFile(Server.M apPath(fName));
bmp=new System.Drawing.Bitmap(1,1);
int height = (int)(fullSizeImg.Height*size);

int width = (int)(fullSizeImg.Width*size);

bmp=(System.Drawing.Bitmap)(ResizeImage(bmp,width, height));
bmp.Save(Response.OutputStream,System.Drawing.Imag ing.ImageFormat.Jpeg);
Martin Schmid, EIT, CCSA, MCDBA, MCSE
Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a
I think you have too much in you page.

get rid of everything after the directives page..

In a very similar webform the only lines in my "webpage" ar
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="ReturnFile.aspx.vb" Inherits="albertphoto.ReturnFile"%



Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.