Dynamic Images in C#

Discussion in 'ASP .Net' started by Martin Schmid, May 5, 2004.

  1. 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?

    --
    Thanks,
    Martin Schmid, EIT, CCSA, MCDBA, MCSE
     
    Martin Schmid, May 5, 2004
    #1
    1. Advertising

  2. 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]
    -

    "Martin Schmid" <> wrote in message
    news:OnEh%...
    > 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?
    >
    > --
    > Thanks,
    > Martin Schmid, EIT, CCSA, MCDBA, MCSE
    >
    >
     
    Nicholas Paldino [.NET/C# MVP], May 5, 2004
    #2
    1. Advertising

  3. 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 [.NET/C# MVP]" <> wrote in
    message news:uyj%...
    > 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]
    > -
    >
    > "Martin Schmid" <> wrote in message
    > news:OnEh%...
    > > 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?
    > >
    > > --
    > > Thanks,
    > > Martin Schmid, EIT, CCSA, MCDBA, MCSE
    > >
    > >

    >
    >
     
    Martin Schmid, May 6, 2004
    #3
  4. Martin Schmid

    H Leboeuf Guest

    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" <> wrote in message
    news:...
    > 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 [.NET/C# MVP]" <> wrote

    in
    > message news:uyj%...
    > > 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]
    > > -
    > >
    > > "Martin Schmid" <> wrote in message
    > > news:OnEh%...
    > > > 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?
    > > >
    > > > --
    > > > Thanks,
    > > > Martin Schmid, EIT, CCSA, MCDBA, MCSE
    > > >
    > > >

    > >
    > >

    >
    >
     
    H Leboeuf, May 7, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest
    Replies:
    4
    Views:
    924
    Eliyahu Goldin
    Jan 4, 2005
  2. Luis Esteban Valencia Muñoz
    Replies:
    0
    Views:
    802
    Luis Esteban Valencia Muñoz
    Jun 3, 2005
  3. wardemon

    Cache Images vs Static Images

    wardemon, Jun 14, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    678
    bruce barker
    Jun 14, 2007
  4. Keith Hughitt
    Replies:
    6
    Views:
    1,101
  5. Adrienne Boswell
    Replies:
    1
    Views:
    525
    dorayme
    Aug 4, 2009
Loading...

Share This Page