Saturday, September 10, 2005
« New LCD Monitor | Main | AJAX-enabled Web Control - Followup #1 »

Troubling Thought #1 - "AJAX-enabled", is that a word??

On we go.

At work, we have us a nice Web Control. Currently I'm adding to it some functionality that will get data from the server without posting-back the whole page.

So I started with implementing this stuff in the most straightforward and naive way possible, because I wanted to see it work. Here's how:

1. I added some custom javascript to the control's behavior file. That javascript catches some client-side events, creates and XMLHTTP object, builds a custom request in XML format, sends it to the server, gets an XML response back, decodes it and displays the data to the user.

2. On the server I wrote me a simple asp.net page(that's ver. 1.1).

In that page's Page_Load I call Request.BinaryRead to get the request XML, then I decode the request, get the needed data, build an XML out of it and then Response.Write it back to the client.

 

And the amazing part is - it works.

 

So now I'm just left not too happy with the implementation. Here are the issues I see:

1. I don't like to see that custom handling of XML encoding/decoding and XMLHTTP-related code in the javascript. Ideally, I want some framework that will handle that for me. What I want is to call a client-side function and have some server-side method get (magically) called for me.

This is exactly what the cool ajax.net framework does, but it does so for Pages. Your server-side method has to reside in some specific Page. And me, I have a web control, not a specific page.

2. Using a standard asp.net Page as an HTTP handler doesn't smell right. And probably performance-wise it's not best either. I probably should implement some IHttpHandler or something (at least that's what I think they're called). I read once that's as easy as getting porn on the internet. But I never actually did it. (The former, that is)

3. On the same note, how am I to deploy the web control now? Telling the users to put a specially designated .aspx file at a fixed location in their web app isn't all that classy, is it?

 

That's it for the real stinking stuff I guess.

I'd appreciate your take on the three issues, and some additional suggestions while you're at it, if you have them.

Thanks.

Want to join me as partner in a cool new startup?
Get in touch: pasha at cohai dot co

Bookmark and Share Sunday, September 11, 2005 12:29:40 AM (Jerusalem Daylight Time, UTC+03:00)  #    Comments [5]  
Monday, September 12, 2005 8:57:58 AM (Jerusalem Daylight Time, UTC+03:00)
Hey there ..

What's up ?

We use XMLHTTP in our web applications .
And till lately we had an aspx file for every page in the application which was handling the xmlhttp request and returned the response .

Inside the "request handler" aspx we had a case statement for every possible action that come from the page that the client see .
For ex: "Update" , "Delete" and etc' .
Mostly what every block inside the case would do is just call some method in the BL dll and pass the params and then return the results.

I've rewritten the whole thing (with my team leader inspiration) to the following way :

Js code call over xmlhttp to aspx which is registered as HttpHandler - which means no such page actually exist ,
and the request goes to the dll/class that is registered as the handler

Then Reflection used to call any method we asked in the request - with some limitation of parameters of primitive type and arrays for now.
Method can reside in any dll .

And then it returns the ret val of the method + ref / out parametes.

For now it's limited to the primitive types in the methods - int , string and etc'. Though it works with arrays too .
(Means you can just send a js array .. the conversion to the xml is done on the client of course.)
At the meantime it does the job pretty good .

And I'm thinking of extending it even more.


Hope the idea can help you somehow..

p.s I've just read about AJAX for the first time - and was very surprised to see that what we're doing is pretty similar to their implementation.
Sunday, April 17, 2011 12:27:15 AM (Jerusalem Daylight Time, UTC+03:00)
Kudos! What a neat way of thiknnig about it.
Sunday, April 17, 2011 8:50:34 PM (Jerusalem Daylight Time, UTC+03:00)
5Ri8dh <a href="http://mqhnfvkmhauw.com/">mqhnfvkmhauw</a>
Saturday, April 23, 2011 7:29:42 PM (Jerusalem Daylight Time, UTC+03:00)
nVtumH <a href="http://pzfibgecfrho.com/">pzfibgecfrho</a>
Monday, April 25, 2011 12:08:50 AM (Jerusalem Daylight Time, UTC+03:00)
RqplhD , [url=http://seqwkvgyfqlz.com/]seqwkvgyfqlz[/url], [link=http://zynocaqbttby.com/]zynocaqbttby[/link], http://antxyksffudu.com/
Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):