 |
|
| .NET DotNet Forum Index » ASP.NET - Webservices Forum » Alternative options for when QueryString exceeds IE... |
|
Page 1 of 1 |
|
| Author |
Message |
| Adam Eccleshall... |
Posted: Wed Aug 19, 2009 8:02 am |
|
|
|
Guest
|
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 |
|
|
| Back to top |
|
|
|
| Patrice... |
Posted: Mon Aug 31, 2009 7:12 am |
|
|
|
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" <AdamEccleshall at (no spam) discussions.microsoft.com> a écrit dans le
message de groupe de discussion :
483A17FC-8803-401C-AC5A-AB34252699F3 at (no spam) microsoft.com...
Quote: 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
|
|
|
| Back to top |
|
|
|
| Adam Eccleshall... |
Posted: Tue Sep 01, 2009 2:16 am |
|
|
|
Guest
|
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:
Quote: 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" <AdamEccleshall at (no spam) discussions.microsoft.com> a écrit dans le
message de groupe de discussion :
483A17FC-8803-401C-AC5A-AB34252699F3 at (no spam) microsoft.com...
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
|
|
|
| Back to top |
|
|
|
| Patrice... |
Posted: Tue Sep 01, 2009 5:21 am |
|
|
|
Guest
|
Quote: 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  |
|
|
| Back to top |
|
|
|
|
|
All times are GMT - 5 Hours
The time now is Sun Nov 29, 2009 7:30 pm
|
|