Alternative options for when QueryString exceeds IE URL length lim

A

Adam Eccleshall

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
 
P

Patrice

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" <[email protected]> a écrit dans le
message de groupe de discussion :
(e-mail address removed)...
 
A

Adam Eccleshall

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.
 
P

Patrice

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 ;-)
 

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

No members online now.

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top