. NET AJAX Brushless new technology

Source: Internet
Author: User
Tags add object config get ip net reference string version
ajax| Refresh | no refresh
"Guide" Ajax technology, known as no refresh, is actually on the Web through JavaScript, using asynchronous XMLHTTP request, to achieve a web interface without refreshing. This article takes you through an example to experience. NET AJAX No Refresh technology ...

download a. NET AJAX Development Kit, which includes Ajax for ASP2.0 and the current ASP1.1 edition, detailed address see http://ajax.schwarz-interactive.de/, Next, start.

1. Create a new item, add a reference to the reference Ajax.dll,ajax.dll is located in the downloaded compressed package.

2. Establish HttpHandler, add in web.config



<add verb= "Post,get" path= "Ajax/*.ashx" type= "Ajax.pagehandlerfactory, Ajax"/>



3. Create a new class Demomethods, this class implementation gets the client MAC address:

using System;

Using System.Web;

Namespace Ajaxsample



Summary description for Methods.


public class Demomethods



public string Getcustomermac (string clientip)//Enter client IP here, this function knowledge test, you can also write a other simple function instead


String mac = "";

System.Diagnostics.Process Process = new System.Diagnostics.Process ();

Process. Startinfo.filename = "nbtstat";

Process. Startinfo.arguments = "-a" +clientip;

Process. Startinfo.useshellexecute = false;

Process. Startinfo.createnowindow = true;

Process. Startinfo.redirectstandardoutput = true;

Process. Start ();

string output = process. Standardoutput.readtoend ();

int length = output. IndexOf ("MAC address =");

if (length>0)


Mac = output. Substring (length+14, 17);


Process. WaitForExit ();

Return Mac. Replace ("-", ""). Trim ();



4. Write JavaScript, create a new file named Default.js as follows

function Getmac ()


var clientip= "";

document.getElementById ("Mac"). Value=demomethods.getcustomermac (ClientIP). Value

Alert (Demomethods.getcustomermac (ClientIP). value);


5. Put an HTML button on an ASPX page

Refer to Default.js on the page
<script Language= "javascript" src= "Default.js" ></script>

Add in the onclick event of input

<input style= "Z-INDEX:101; left:392px; Position:absolute; top:176px "type=" button "

value= "Client Get IP" >

6. Add the Page_Load event to the page page

private void Page_Load (object sender, System.EventArgs e)


Place user code here to initialize page

Ajax.Utility.RegisterTypeForAjax (typeof (Ajaxsample.demomethods));


Note: in typeof (Ajaxsample.demomethods), Ajaxsample is a namespace, Demomethods is the class that contains the method to invoke, that is, step 3rd above. New Class Demomethods

7. Modify the Global.asax Application_Start event and set the Ajax Handlerpath:

protected void Application_Start (Object sender, EventArgs e)


Ajax.Utility.HandlerPath = "Ajax";


Run to see the effect. is the MAC address of the client that is not refreshed on the server side?

It should be noted that this version of. NET AJAX requires manual global.asax plus Ajax.Utility.HandlerPath = "Ajax"; Configuration file web.config must add HttpHandler configuration information!

The new version of the development package has not had time to experience, it is estimated that the new version will be more convenient, may remove the manual settings Global.asax Application_Start event plus Ajax.Utility.HandlerPath = "Ajax"; and other troublesome settings!


Related Article

Cloud Intelligence Leading the Digital Future

Alibaba Cloud ACtivate Online Conference, Nov. 20th & 21st, 2019 (UTC+08)

Register Now >

Starter Package

SSD Cloud server and data transfer for only $2.50 a month

Get Started >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.