First declare the following points:
1, explain if the feeling is very elementary, even if I loaded 13, do not "spray" Me Oh!
2, if there are those places wrong, but also hope that we can correct, must humbly consult;
3, this is only opinion, my experience, no basis, love believe it or not.
Here's the lecture:
To talk about Ajax has done web development is very familiar with, is through the process XMLHTTP request and server-side communication and avoid page press F5. That is, we often say "no refresh", as for this principle I do not understand, which understand the words, teach me ah, thank you!
To use Ajaxpro, we generally have to do the following tasks:
1, in the project to add a reference ajaxpro.2.dll, this to the Internet next, if not, I have the time to share the words;
2. Add < in Web.config configuration file
Add verb= "Post,get" path= "Ajaxpro/*.ashx" type= "ajaxpro.ajaxhandlerfactory,ajaxpro.2"/> Node;
3, on the page to use AJAX features, CS file to register Ajax, for example:
protected void Page_Load (Object Sender,eventargs e)
{//Register Ajax Ajaxpro.utility.registertypeforajax (typeof (Default));}
4. Declare a method (or property) that can be invoked by Ajax in a. cs file, such as:
[Ajaxpro.ajaxmethod]
public string Getstr () {return "str";}
5. Add JS to the
Copy Code code as follows:
<script language= "JavaScript" >
var item=dynloadtree.default.getstr (). Value;//ajax Call Background method
alert (item);
</script>
Do the above five steps, we basically realize the Ajax page does not press F5 function. So how does it communicate with the server through a process XMLHTTP? After running we can see the source code of the HTML file a few more lines. ashx File cache:
Copy Code code as follows:
<script type= "Text/javascript" src= "/ajaxpro/prototype.ashx" </script>
<script type= "Text/javascript" src= "/ajaxpro/core.ashx" </script>
<script type= "Text/javascript" src= "/ajaxpro/converter.ashx" </script>
<script> type= "Text/javascript" src= "/ajaxpro/dynloadtree.default,dynloadtree.ashx" </script>
In fact, these. Ashx is automatically added to the HTML document output when you register Ajax in the 3rd step above Ajaxpro.utility.registertypeforajax. What documents are these documents? Looking at the configuration added to the httphandlers section in the 2nd step in web.config, it tells the system that any request that has been ashx as a suffix under the Ajaxpro path is given to the Ajaxpro.ajaxhandlerfactory class, which is processed and returned Back is a few JavaScript files, and the normal JS cache there is no real difference.
All right, that's all I'm saying. If you're interested, you can study the functions in each. ashx file. Alas, I do not have time to make, online also has a lot of information about this, there are cattle x directly to the Ajaxpro.2.dll decompile, we can also go to see the code inside, perhaps more harvest, hehe ...
Ps:tandy Tang Wishes everybody writes the code to write happily!