Alternative options for when QueryString exceeds IE URL length lim

Discussion in 'ASP .Net Web Services' started by Adam Eccleshall, Aug 19, 2009.

  1. Hi,

    I don't know if this is the right forum for this question - if not, please
    point me at the right one.

    I have a website .dll / .aspx project in VS2005 which receives a string of
    parameters in the query string and returns a PNG image in the HTTP response.

    The current form of the program is


    -----------------------
    Bitmap bitmap = new Bitmap(500, 100);
    Graphics graphics = Graphics.FromImage(bitmap);
    graphics.SmoothingMode = SmoothingMode.AntiAlias;

    Font displayFont = new Font("Times New Roman", 32);
    Color displayColour = Color.FromArgb(128, 128, 128);
    Brush displayBrush = new SolidBrush(displayColour);
    Pen pen = new Pen(displayColour);


    System.Collections.Specialized.NameObjectCollectionBase.KeysCollection Keys =
    this.Request.QueryString.Keys;

    // Do something with the query string

    // Make sure the browser interprets it as the right type
    this.Response.ContentType = "image/png";
    this.Response.StatusCode = 200;

    // Write the image to the http response via a memory stream
    MemoryStream ms = new System.IO.MemoryStream();
    bitmap.Save(ms, ImageFormat.Png);
    ms.WriteTo(this.Response.OutputStream);
    -----------------------


    This code is called via <img
    src="http://someurl/DynamicImage.aspx?someparameters">, and generally works
    as expected. the problem is that due to the nature of the date it uses, it
    is quite easy for the parameter list to puch the URL beyond the 2083
    character limit, thus returning either a bad image or (if I truncate the URL
    before the call), an incomplete representation of the data.

    Is there some way I can modify my code such that it doesn't need to use the
    query string? I thought of using POST to send the data rather than GET, but
    the images need to be embedded in non-form pages.

    Is there, perhaps, a way of reading attributes in the <img> tag, or are they
    client-side only?


    Thank you,

    Adam
    Adam Eccleshall, Aug 19, 2009
    #1
    1. Advertising

  2. Adam Eccleshall

    Patrice Guest

    Hi,

    You could perhaps register somewhere (file, db, memory etc...) the
    parameters using a GUID and then pass just this GUID on the query string to
    represent the parameters you are interested in... This way you won't have
    any limit at all...

    Another option could be to be able to expand those dates from an abbreviated
    form to save space (you'll still have a limit it will just a bit higher).
    Hard to suggest how to compact wihtout knowing the format you currently use
    (for example you could use a YYMMDD format to use 6 characters for each
    date).

    --
    Patrice

    "Adam Eccleshall" <> a écrit dans le
    message de groupe de discussion :
    ...
    > Hi,
    >
    > I don't know if this is the right forum for this question - if not, please
    > point me at the right one.
    >
    > I have a website .dll / .aspx project in VS2005 which receives a string of
    > parameters in the query string and returns a PNG image in the HTTP
    > response.
    >
    > The current form of the program is
    >
    >
    > -----------------------
    > Bitmap bitmap = new Bitmap(500, 100);
    > Graphics graphics = Graphics.FromImage(bitmap);
    > graphics.SmoothingMode = SmoothingMode.AntiAlias;
    >
    > Font displayFont = new Font("Times New Roman", 32);
    > Color displayColour = Color.FromArgb(128, 128, 128);
    > Brush displayBrush = new SolidBrush(displayColour);
    > Pen pen = new Pen(displayColour);
    >
    >
    > System.Collections.Specialized.NameObjectCollectionBase.KeysCollection
    > Keys =
    > this.Request.QueryString.Keys;
    >
    > // Do something with the query string
    >
    > // Make sure the browser interprets it as the right type
    > this.Response.ContentType = "image/png";
    > this.Response.StatusCode = 200;
    >
    > // Write the image to the http response via a memory stream
    > MemoryStream ms = new System.IO.MemoryStream();
    > bitmap.Save(ms, ImageFormat.Png);
    > ms.WriteTo(this.Response.OutputStream);
    > -----------------------
    >
    >
    > This code is called via <img
    > src="http://someurl/DynamicImage.aspx?someparameters">, and generally
    > works
    > as expected. the problem is that due to the nature of the date it uses,
    > it
    > is quite easy for the parameter list to puch the URL beyond the 2083
    > character limit, thus returning either a bad image or (if I truncate the
    > URL
    > before the call), an incomplete representation of the data.
    >
    > Is there some way I can modify my code such that it doesn't need to use
    > the
    > query string? I thought of using POST to send the data rather than GET,
    > but
    > the images need to be embedded in non-form pages.
    >
    > Is there, perhaps, a way of reading attributes in the <img> tag, or are
    > they
    > client-side only?
    >
    >
    > Thank you,
    >
    > Adam
    >
    Patrice, Aug 31, 2009
    #2
    1. Advertising

  3. Re: Alternative options for when QueryString exceeds IE URL length

    Thank you.

    I actually noticed when reading my quoted original mail in your reply that
    there were a couple of key typos, notably "date" was actually supposed to
    read "data", however your idea of reducing the format proved valuable - I
    changed the bases of all the numbers I needed to send, significantly reducing
    the length of the url.

    "Patrice" wrote:

    > Hi,
    >
    > You could perhaps register somewhere (file, db, memory etc...) the
    > parameters using a GUID and then pass just this GUID on the query string to
    > represent the parameters you are interested in... This way you won't have
    > any limit at all...
    >
    > Another option could be to be able to expand those dates from an abbreviated
    > form to save space (you'll still have a limit it will just a bit higher).
    > Hard to suggest how to compact wihtout knowing the format you currently use
    > (for example you could use a YYMMDD format to use 6 characters for each
    > date).
    >
    > --
    > Patrice
    >
    > "Adam Eccleshall" <> a écrit dans le
    > message de groupe de discussion :
    > ...
    > > Hi,
    > >
    > > I don't know if this is the right forum for this question - if not, please
    > > point me at the right one.
    > >
    > > I have a website .dll / .aspx project in VS2005 which receives a string of
    > > parameters in the query string and returns a PNG image in the HTTP
    > > response.
    > >
    > > The current form of the program is
    > >
    > >
    > > -----------------------
    > > Bitmap bitmap = new Bitmap(500, 100);
    > > Graphics graphics = Graphics.FromImage(bitmap);
    > > graphics.SmoothingMode = SmoothingMode.AntiAlias;
    > >
    > > Font displayFont = new Font("Times New Roman", 32);
    > > Color displayColour = Color.FromArgb(128, 128, 128);
    > > Brush displayBrush = new SolidBrush(displayColour);
    > > Pen pen = new Pen(displayColour);
    > >
    > >
    > > System.Collections.Specialized.NameObjectCollectionBase.KeysCollection
    > > Keys =
    > > this.Request.QueryString.Keys;
    > >
    > > // Do something with the query string
    > >
    > > // Make sure the browser interprets it as the right type
    > > this.Response.ContentType = "image/png";
    > > this.Response.StatusCode = 200;
    > >
    > > // Write the image to the http response via a memory stream
    > > MemoryStream ms = new System.IO.MemoryStream();
    > > bitmap.Save(ms, ImageFormat.Png);
    > > ms.WriteTo(this.Response.OutputStream);
    > > -----------------------
    > >
    > >
    > > This code is called via <img
    > > src="http://someurl/DynamicImage.aspx?someparameters">, and generally
    > > works
    > > as expected. the problem is that due to the nature of the date it uses,
    > > it
    > > is quite easy for the parameter list to puch the URL beyond the 2083
    > > character limit, thus returning either a bad image or (if I truncate the
    > > URL
    > > before the call), an incomplete representation of the data.
    > >
    > > Is there some way I can modify my code such that it doesn't need to use
    > > the
    > > query string? I thought of using POST to send the data rather than GET,
    > > but
    > > the images need to be embedded in non-form pages.
    > >
    > > Is there, perhaps, a way of reading attributes in the <img> tag, or are
    > > they
    > > client-side only?
    > >
    > >
    > > Thank you,
    > >
    > > Adam
    > >

    >
    >
    Adam Eccleshall, Sep 1, 2009
    #3
  4. Adam Eccleshall

    Patrice Guest

    Re: Alternative options for when QueryString exceeds IE URL length

    > I actually noticed when reading my quoted original mail in your reply that
    > there were a couple of key typos, notably "date" was actually supposed to
    > read "data", however your idea of reducing the format proved valuable - I
    > changed the bases of all the numbers I needed to send, significantly
    > reducing
    > the length of the url.


    Ok, as you see typos doesn't matter ;-)
    Patrice, Sep 1, 2009
    #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. =?Utf-8?B?Z2xlbm4=?=
    Replies:
    0
    Views:
    312
    =?Utf-8?B?Z2xlbm4=?=
    Jun 22, 2006
  2. Replies:
    5
    Views:
    2,982
  3. Michael B Allen

    How to make (ptr + len) > lim safe?

    Michael B Allen, Jan 17, 2008, in forum: C Programming
    Replies:
    26
    Views:
    750
    William Ahern
    Jan 20, 2008
  4. Adeel Ahmad
    Replies:
    1
    Views:
    301
    Anthony Jones
    Mar 7, 2006
  5. Ben
    Replies:
    7
    Views:
    412
    Dave Anderson
    May 17, 2006
Loading...

Share This Page