<ccid_code></ccid_code><configuration> < system.web> < httpHandlers> <add verb="POST,GET" path="ajax/*.ashx" type="Ajax.PageHandlerFactory, Ajax" /> </httpHandlers> <system.web> </configuration> |
<ccid_code></ccid_code>using System; using System.Web; namespace AjaxSample { /**//// <summary> /// Summary description for Methods. /// </summary> public class DemoMethods { [Ajax.AjaxMethod] public string GetCustomerMac(string clientIP) //这里输入客户端IP,这个函数知识测试用,你也可以写一个其他的简单一点的函数代替 { tring mac = ""; System.Diagnostics.Process process = new System.Diagnostics.Process(); rocess.StartInfo.FileName = "nbtstat"; rocess.StartInfo.Arguments = "-a "+clientIP; rocess.StartInfo.UseShellExecute = false; rocess.StartInfo.CreateNoWindow = true; rocess.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(); } }} |
<ccid_code></ccid_code>function GetMac() { var clientIP="192.168.0.1"; //document.getElementById("Mac").value =DemoMethods.GetCustomerMac(clientIP).value alert(DemoMethods.GetCustomerMac (clientIP).value); } |
<ccid_code></ccid_code><script language="javascript" src="default.js"> </script> |
<ccid_code></ccid_code>onclick="javascript:GetMac()"< INPUT style="Z-INDEX: 101; LEFT: 392px; POSITION: absolute; TOP: 176px" type="button"> |
value="客户端获取IP" onclick="javascript:GetMac();">
6.在page页面的Page_Load事件中加上
<ccid_nobr></ccid_nobr><ccid_code></ccid_code>private void Page_Load (object sender, System.EventArgs e) { // 在此处放置用户代码以初始化页面 Ajax.Utility.RegisterTypeForAjax (typeof(AjaxSample.DemoMethods)); } |
<ccid_code></ccid_code>protected void Application_Start (Object sender, EventArgs e) { Ajax.Utility.HandlerPath = "ajax"; } |