Re: JavaScriptConverter for Bitmaps



Problem is the images don't exist until requested, i.e they are generated
from some backend stats analysis.
I thought of maybe using a custom handler that implements IHttpAsyncHandler
and set the maxconnections section of the web.config to a higher number.

Would that do it. I really want to try and get the page (which has any where
up to 10 of these images) to be as quick to download.

Is there anyway to break to 2 request barrier. I have full control over
settings on the web app and webservice.

Thanks for your help so far.

MattC

"bruce barker" <nospam@xxxxxxxxxx> wrote in message
news:%23CRaiN$kHHA.4188@xxxxxxxxxxxxxxxxxxxxxxx
ajax is limted to 2 concurrent requests also (IE treats it as another http
request). this is to be friendly to web servers.

note: if you use session with your webservice you will be limited to one
request at a time as requests for the same session are queued on the
server side.

if you want performance, iis serves up images a lot faster then asp.net
can.

-- bruce (sqlwork.com)

MattC wrote:
Yeah I tried the base64 route but IE ignores the data:image/gif;base64
part and is limted to 1024bytes.

I can do it using using the src set to the webservice but IE only makes 2
HTTP requests at the same time. I thought possibly that the AJAX
webrequests would not be bound by IE's request limit and allow, say all
20 requests to fire off to the webservice.

MattC


"bruce barker" <nospam@xxxxxxxxxx> wrote in message
news:eF5H0E%23kHHA.1340@xxxxxxxxxxxxxxxxxxxxxxx
javascript does not have a bitmap datatype (nor binary) so there is
nothing to serialize to. the normal way would be to base64 encode the
bitmap to string, then send the string.

why are you passing an image thru ajax? javascript can not display a
bitmap directly anyway. javascript can create a new Image() and set its
url to fetch from the server, or set the src of an <img> to display an
image. no ajax required.

-- bruce (sqlwork.com)

MattC wrote:
Hi,

I've got a webservice that returns a System.Drawing.Image. I'm calling
the webservice via AJAX all goes well but my JSON converter seralize
method gets called repeatedly and causes a
An unhandled exception of type 'System.StackOverflowException' occurred
in mscorlib.dll

Hope you can help.
TIA

MattC - code bellow

Service:

[WebMethod]
[ScriptMethod]
public System.Drawing.Image ChartDataTwo(){...}


AJAX Call:

TestingGround.AJAXServices.LocalChartService.ChartDataTwo(SuccessCallBack,
FailedCallback);

And the callback on success

function OnCompleteImageService(results)
{
var obj =
Sys.Serialization.JavaScriptSerializer.deserialize(results);
document.getElementById('ImageService').src = obj;
}



And my JSON Converter

class AjaxImageConvert : JavaScriptConverter
{

public override IDictionary<string, object> Serialize(object
obj, JavaScriptSerializer serializer)
{
Bitmap i;

//obj comes in as a Bitmap check why later
if (obj is Bitmap)
{
i = (Bitmap)obj;

Dictionary<string, object> result = new
Dictionary<string, object>();

result["CustomImage"] = i;

return result;
}
return new Dictionary<string, object>();
}

public override IEnumerable<Type> SupportedTypes
{
get { return new ReadOnlyCollection<Type>(new
List<Type>(new Type[] { typeof(Bitmap) })); }
}

public override object Deserialize(IDictionary<string, object>
dictionary, Type type, JavaScriptSerializer serializer)
{
object obj = (object)dictionary["CustomImage"];
return obj;
}

}


And registered

<jsonSerialization maxJsonLength="500000">
<converters>
<add name="AjaxImageConvert"
type="CustomControls.AjaxImageConvert"/>
</converters>
</jsonSerialization>


.



Relevant Pages

  • Re: Cheap Access to Space
    ... WITH images and illustrations of the B2 Bomber which admittedly heats ... From a FOIA I tried filling with NASA: ... I hereby request any documents, images, memos or other items ... classification of non-Earth images or data, of any type, in any manner ...
    (sci.space.policy)
  • Re: Printing website - cookies
    ... would be requested with the Print command so that the latest version of any ... gets that cookie). ... At the request of any "private" article or image, ... All "private" images in the article turn out, on paper, as the default ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: IHE - multiple orders - one exam - how to act as PACS/RIS?
    ... which were performed/satified by the acquisition of the images as ... separate items in the Request Attributes Sequence. ... your trigger to definitely go look for multiple requested procedure ...
    (comp.protocols.dicom)
  • Re: Resource protected by Form based aythetication
    ... select the Directory Tab and hit the configuration button. ... On the Mappings tab, add a new mapping. ... This maps the request to ASP.NET which will then honor your security settings. ... All my aspx forms located in Demo folder and image files located in a subfolder of Demo, named images. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Application quit when i set ProgressBar.Minimum and ProgressBar.Maximum with the same value
    ... There could be a problem if the pseudocode below is invoked on a secondary ... "Request" means a package of data need to ... > by webservice then insert into SQL CE ... In my case, my SQL ...
    (microsoft.public.dotnet.framework.compactframework)

Quantcast