Dynamic Images in C#

M

Martin Schmid

I Have a C# asp app that returns an image to the browser (I'm using IE6) as
follows:

Response.ContentType="image/jpeg";
bmp.Save(Response.OutputStream,System.Drawing.Imaging.ImageFormat.Jpeg);

However, when I right click on the resulting image in the browser window to
"Save Picture As..." it is saving the calling webform.aspx file (a text
document)...

The result.aspx file contains only the following:

<%@ Page language="c#" AutoEventWireup="false" Codebehind="Result.aspx.cs"
Inherits="spc.Result" %>

I have noticed that if I change the encoding (i.e., right click in the
browser, and selecting any encoding method other than what is current, I can
right click and save the jpeg image (defaults to Result.jpg). But... I
don't want users to have to go through that...

I can set as Background (windows desktop) image from the browser... (w/o
changing the encoding), but emailing the image from the browser prepares an
email containing some funkified version of the calling webform.aspx.

Any ideas?
 
N

Nicholas Paldino [.NET/C# MVP]

Martin,

I believe that setting the content disposition header will alleviate
this. You can do it like this:

Response.AddHeader("content-disposition", string.Concat("attachment;
filename=", <filename>));

Then, when you right click, it should show the filename you specify, and
save the actual image.

Hope this helps.
 
M

Martin Schmid

This is causing a pop-up dialog:
'Some files can harm your computer. If the file information below looks
suspicious, or you do not fully trust the source, do not open or save this
file.
File name: <whatever I want>
File type: JPEG Image
From: <this machine>
Would you like to open the file... open/save/cancel/more info...


What can be done to not cause this? I.e., jpeg is typically trustworthy,
no? This shouldn't be raising an alarm on the user's end/


--
Thanks,
Martin Schmid, EIT, CCSA, MCDBA, MCSE

Nicholas Paldino said:
Martin,

I believe that setting the content disposition header will alleviate
this. You can do it like this:

Response.AddHeader("content-disposition", string.Concat("attachment;
filename=", <filename>));

Then, when you right click, it should show the filename you specify, and
save the actual image.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Martin Schmid said:
I Have a C# asp app that returns an image to the browser (I'm using IE6) as
follows:

Response.ContentType="image/jpeg";
bmp.Save(Response.OutputStream,System.Drawing.Imaging.ImageFormat.Jpeg);

However, when I right click on the resulting image in the browser window to
"Save Picture As..." it is saving the calling webform.aspx file (a text
document)...

The result.aspx file contains only the following:

<%@ Page language="c#" AutoEventWireup="false" Codebehind="Result.aspx.cs"
Inherits="spc.Result" %>

I have noticed that if I change the encoding (i.e., right click in the
browser, and selecting any encoding method other than what is current, I can
right click and save the jpeg image (defaults to Result.jpg). But... I
don't want users to have to go through that...

I can set as Background (windows desktop) image from the browser... (w/o
changing the encoding), but emailing the image from the browser prepares an
email containing some funkified version of the calling webform.aspx.

Any ideas?
 
H

H Leboeuf

Tools/Internet Options/Security/Custom level.

Some settings are set to Prompt. Check it out.
--

Henri Leboeuf
Web page: http://www.colba.net/~hlebo49/index.htm
===

Martin Schmid said:
This is causing a pop-up dialog:
'Some files can harm your computer. If the file information below looks
suspicious, or you do not fully trust the source, do not open or save this
file.
File name: <whatever I want>
File type: JPEG Image
From: <this machine>
Would you like to open the file... open/save/cancel/more info...


What can be done to not cause this? I.e., jpeg is typically trustworthy,
no? This shouldn't be raising an alarm on the user's end/


--
Thanks,
Martin Schmid, EIT, CCSA, MCDBA, MCSE

message news:uyj%[email protected]...
Martin,

I believe that setting the content disposition header will alleviate
this. You can do it like this:

Response.AddHeader("content-disposition", string.Concat("attachment;
filename=", <filename>));

Then, when you right click, it should show the filename you specify, and
save the actual image.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Martin Schmid said:
I Have a C# asp app that returns an image to the browser (I'm using
IE6)
as
follows:

Response.ContentType="image/jpeg";
bmp.Save(Response.OutputStream,System.Drawing.Imaging.ImageFormat.Jpeg);

However, when I right click on the resulting image in the browser
window
to
"Save Picture As..." it is saving the calling webform.aspx file (a tex t
document)...

The result.aspx file contains only the following:

<%@ Page language="c#" AutoEventWireup="false" Codebehind="Result.aspx.cs"
Inherits="spc.Result" %>

I have noticed that if I change the encoding (i.e., right click in the
browser, and selecting any encoding method other than what is current,
I
can
right click and save the jpeg image (defaults to Result.jpg). But... I
don't want users to have to go through that...

I can set as Background (windows desktop) image from the browser... (w/o
changing the encoding), but emailing the image from the browser
prepares
an
email containing some funkified version of the calling webform.aspx.

Any ideas?
 

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,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top