Injecting image page element without calling ASPX page?

Discussion in 'ASP .Net' started by Christopher Ambler, Aug 26, 2003.

  1. I'm wondering if there's a solution here -

    I have an ASPX page with a sole purpose of scaling an image. The ASPX page
    contains a single line with the codebehind tag, and the .cs file contains
    the code to read an image, use GDI+ to scale it to a reasonable size, and
    emit the image directly (setting content-type on the response and spitting
    out the bytes for the image).

    What I'd love to do would be to eliminate the ASPX page and be able to call
    a routine in my compiled code directly. Since this code will be delivered to
    a customer, that would get rid of the extra ASPX page and make it much more
    elegant.

    But since the ASPX page is called in an "img" tag, I can't see a way to do
    this. Obviously, I need the img tag in the display file, but is there a way
    to specify that the content comes from code rather than another page? Can
    the img tag be runat-server and inject the image directly in codebehind?

    Anyone have a clue for me?

    Many thanks!

    Christopher
     
    Christopher Ambler, Aug 26, 2003
    #1
    1. Advertising

  2. Christopher Ambler

    Lucas Tam Guest

    "Christopher Ambler" <> wrote in
    news:udV$4y$:

    > But since the ASPX page is called in an "img" tag, I can't see a way
    > to do this. Obviously, I need the img tag in the display file, but is
    > there a way to specify that the content comes from code rather than
    > another page? Can the img tag be runat-server and inject the image
    > directly in codebehind?


    I don't think so... because the browser needs to create a new connection to
    download the graphics image. The new connection would contain the binary
    image data. If you placed all the code on one page, the binary data would
    be mixed in with your html data, thus corrupting the display : (

    --
    Lucas Tam ()
    Please delete "REMOVE" from the e-mail address when replying.
    http://members.ebay.com/aboutme/coolspot18/
     
    Lucas Tam, Aug 26, 2003
    #2
    1. Advertising

  3. HttpHandlers I understand - I implemented one to do image download control
    (intercepted requests for .JPG and return "Please do not directly access
    this image").

    So what you're saying is, instead of implemeting an ASPX file with the
    codebehind, implement an HttpHandler. Instead of calling an IMG tag with the
    ASPX page and the image I want served on the command line, call and IMG tag
    with, say, the source as "dir1/dir2/imagename.xxx" where "xxx" is any
    extension I want. I could then have the handler intercept that call, parse
    the URI to find the image, perform its magic, and return the image.

    Nice! I'd not considered this solution. Many thanks!

    Christopher

    "John Saunders" <> wrote in message
    news:...
    > "Christopher Ambler" <> wrote in message
    > news:udV$4y$...
    > > I'm wondering if there's a solution here -
    > >
    > > I have an ASPX page with a sole purpose of scaling an image. The ASPX

    page
    > > contains a single line with the codebehind tag, and the .cs file

    contains
    > > the code to read an image, use GDI+ to scale it to a reasonable size,

    and
    > > emit the image directly (setting content-type on the response and

    spitting
    > > out the bytes for the image).
    > >
    > > What I'd love to do would be to eliminate the ASPX page and be able to

    > call
    > > a routine in my compiled code directly. Since this code will be

    delivered
    > to
    > > a customer, that would get rid of the extra ASPX page and make it much

    > more
    > > elegant.

    >
    > You are describing an HttpHandler. See "
    > Securely Implement Request Processing, Filtering, and Content Redirection
    > with HTTP Pipelines in ASP.NET"
    >

    at(http://msdn.microsoft.com/msdnmag/issues/02/09/httppipelines/default.aspx
    > ). Here's an example .ashx file from that article:
    >
    > <%@ WebHandler language="C#" class="Pipeline.TimeHandler" %>
    >
    > using System;
    > using System.Web;
    >
    > namespace Pipeline
    > {
    >
    > public class TimeHandler : IHttpHandler
    > {
    > void ProcessRequest(HttpContext ctx)
    > {
    > // set response message MIME type
    > ctx.Response.ContentType = "text/xml";
    > // write response message body
    > ctx.Response.Write("<now>");
    > ctx.Response.Write(
    > DateTime.Now.ToString());
    > ctx.Response.Write("</now>");
    > }
    > bool IsReuseable { get { return true; } }
    > }
    > }
    >
    > --
    > John Saunders
    > Internet Engineer
    >
    >
    >
     
    Christopher Ambler, Aug 27, 2003
    #3
    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. Peter  Nofelt
    Replies:
    2
    Views:
    488
    Peter Nofelt
    Sep 13, 2005
  2. Rob Reagan

    Injecting a Style Sheet to a Master Page

    Rob Reagan, Nov 27, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    373
    =?Utf-8?B?Q2lhcmFuIE8nJ0Rvbm5lbGw=?=
    Nov 27, 2006
  3. Replies:
    2
    Views:
    300
    bruce barker
    Apr 20, 2008
  4. Andy B
    Replies:
    4
    Views:
    447
    Andy B
    Apr 26, 2008
  5. Peter  Nofelt

    webservices, return xml without .net injecting xml schema

    Peter Nofelt, Sep 13, 2005, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    112
    Peter Nofelt
    Sep 13, 2005
Loading...

Share This Page