×

Loading...
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。

Acturally building a ajax module is not that difficult.

A few years ago I was working on a new .Net project and just heard Ajax, I thought it would be cool to use it, but there is no Ajax module on .Net then (.Net 1.0). I found a php module Sajax and read the client /server side code.

It's not that difficult. core function is just a few hundred lines to call XMLHttp. you write a javascript line call_server_function(function1, para1, para2), it generate a http request to server. server will then call a function.

So I modified the client side script ( might have copyright problem but I don't care), wrote my own server side class to handle ajax calls by reflection. It's working pretty good and the customer is still using it.
Report

Replies, comments and Discussions:

  • 工作学习 / 学科技术讨论 / holdon,打发打发时间,关于只接受browser提交的login,我自创个方法(可能有雷同):HttpWebRequest应该没有运行JavaScript的能力,这样,在onload中用ajax从server端获得一个数字签名,提交(submit)时在server端验证签名。点评一下。
    • HttpWebRequest can't run javascipt, ture. but you can parse the response, find out what need to be run, and run it as C#. e.g. start another httpwebrequest as ajax call.
      As long as you "Know" the web site, you can access it by browser, check the returned html source, see what's inside it , and programing your C# application to do same thing. Anything javascript can do, C# should also be able to do it.



      Right now, the only pratical solution I saw is embed a image and ask the user to type in what's inside the image.
      • Just returned from a meeting. Ajax can call a server side function. I don't think httpwebrequest can call a public function belonged to a web page. BTW, nothing is impossible. but I think it's enough for most of web sites.
        • You don't get it. What is a Ajax call? it's a http request from Javascript. on server side, it's a http request. Again, there is no way server can tell if this call is from a XMLObject, or a WebRequest.
          • Technically you're right. But in .NET framework 3.5, there are lots of preimplemented features (both on server side and client side) for ajax. You need dig out httprequest pattern of ajax so that you can use httpwebrequest to mimic ajax call.
            • You are so into .NET, AJAX and HttpWebRequest those stuff. All they do are just sending plain text to remote server. That's it, nothing more. HTTP hasn't been changed for years.
              • yeah, right. Like google map using httpwebrequest. but I just wonder how many web developer can develope google map?
              • some .Net developers are a little bit narrow minded. carletonwong is asking how to download ssl site files by .Net client; he didn't say one word if the server is .Net. lots of .Net developers assume it's .Net server.
                Later, turnned out the server is not IIS .

                IIS probably doesn't have half web server market so it's not ture that most internet application use form authentication.

                When I talk about ajax, I am saying generally it's doable to use httpwebrequest (or php/perl, even wget) to call a ajax server side function, Did I say the server is .Net 3.5?

                Even if it's Net 3.5, I won't image it's that difficult to program a http client to call the server side function, not as difficult as developing google map for sure.

                Say I got such a request, what I would do is to build a simple 3.5 application first, run some simple ajax calls and dump all the raw request on the server side.
                • 呵呵,.NET不是天外来客,任何.NET能实现的事情,别的环境也都能实现,即使不叫Form authentication,也是用cookie来放security token的。
                  至于AJAX,在100%javascript上讨论也是吹吹牛而已,就象有人说可以用notepad开发网站。.NET也好,Java也好,或者别的环境,如果没有支持Ajax的模块,要开发Ajax程序无异是相当地困难。

                  难度不在"http client to call the server side function"。
                  难度在
                  1:多次call必须call在同一个session。(这个其实也不难)。
                  2:加密的key藏在某个信息中。(这个就比较烦)
                  3: 当然还得写parse httpresponse的代码。
                  • Acturally building a ajax module is not that difficult.
                    A few years ago I was working on a new .Net project and just heard Ajax, I thought it would be cool to use it, but there is no Ajax module on .Net then (.Net 1.0). I found a php module Sajax and read the client /server side code.

                    It's not that difficult. core function is just a few hundred lines to call XMLHttp. you write a javascript line call_server_function(function1, para1, para2), it generate a http request to server. server will then call a function.

                    So I modified the client side script ( might have copyright problem but I don't care), wrote my own server side class to handle ajax calls by reflection. It's working pretty good and the customer is still using it.
                    • Ajax="use javascript to send xml string to http server". So you can simply use ASP and no-third party javascript to write a so called AJAX server. IE and FF both provides native xmlhttp support.
                      • the request is http, not necessarily xml string. the response can also be anything, but because javascipt can understand xml, most ajax library use xml.