惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

爱范儿
爱范儿
博客园_首页
W
WeLiveSecurity
S
Secure Thoughts
S
Security @ Cisco Blogs
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Hugging Face - Blog
Hugging Face - Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
H
Hacker News: Front Page
Project Zero
Project Zero
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
U
Unit 42
N
News and Events Feed by Topic
N
News and Events Feed by Topic
Hacker News - Newest:
Hacker News - Newest: "LLM"
Forbes - Security
Forbes - Security
T
Tor Project blog
I
Intezer
B
Blog
F
Full Disclosure
Security Archives - TechRepublic
Security Archives - TechRepublic
F
Fortinet All Blogs
Schneier on Security
Schneier on Security
T
Threat Research - Cisco Blogs
AI
AI
Google DeepMind News
Google DeepMind News
L
LINUX DO - 最新话题
Cloudbric
Cloudbric
L
Lohrmann on Cybersecurity
WordPress大学
WordPress大学
博客园 - 聂微东
雷峰网
雷峰网
P
Privacy International News Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
PCI Perspectives
PCI Perspectives
Y
Y Combinator Blog
Spread Privacy
Spread Privacy
Simon Willison's Weblog
Simon Willison's Weblog
罗磊的独立博客
Vercel News
Vercel News
A
Arctic Wolf
The Register - Security
The Register - Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Microsoft Azure Blog
Microsoft Azure Blog
H
Heimdal Security Blog
Know Your Adversary
Know Your Adversary
P
Proofpoint News Feed
C
Cybersecurity and Infrastructure Security Agency CISA
P
Proofpoint News Feed

博客园 - 李晓

离开程序员的行业3年了,这次回来,心情波动很大 现在不做程序员了,不会了 现在的生活 芙蓉姐姐大片美若天仙 - 李晓 - 博客园 博客地图怎么做? 我是一个很不称职的管理员 写了一个以树形显示文档库的WEBPART,可根据权限显示文档库 更正用AJAX实现IE TREE无刷新取值的方法 转发: Visual Studio 2005常用插件 转发:编程之余保护眼睛[不断更新ing...] 转发:Session研习笔记 转发:使用JavaScript删除ASP.NET生成的HttpCookie 大病了一场,不过闲时对AJAX探索时,实现了IE TREE无刷新 提供可在WSS上使用的MYTREE 2006年的长春.NET俱乐部 关于WSS搜索的问题 在将WEBPART打包成*.CAB包和*.MSI安装包后,竟然无法将其安装到指定的WSS网站 关于AJAX开发 在C#中实现MSN消息框的功能
AJAX(2)
李晓 · 2005-12-15 · via 博客园 - 李晓

在网上找到了一篇关于AJAX的文章,共享一下给大家看.多学一门新技术总是好的!

.NET Ajax的无刷新技术实例详解


  下载一个.net Ajax开发包,该开发包包括ASP2.0和目前ASP1.1版使用的Ajax,详细地址参见http://ajax.schwarz-interactive.de/,接下来,开始。

  1. 新建一个项目,在引用中添加引用Ajax.dll,Ajax.dll位于下载的压缩包里面。

  2.建立HttpHandler,在web.config里面加上:

<configuration>

lt;
system.web>

lt;
httpHandlers>

lt;
add verb="POST,GET" 
path="ajax/*.ashx"
type="Ajax.PageHandlerFactory,
Ajax" />

lt;
/httpHandlers> 

<system.web>

lt;
/configuration>

  3.新建一个类DemoMethods,这个类实现获取客户端MAC地址:
using System;

using System.Web;

namespace AjaxSample

{

/**//// <summary>

/// Summary description for Methods.

/// </summary>

ublic class DemoMethods

{

[Ajax.AjaxMethod]

ublic 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();

}

}}

  4.写javascript,新建一个名为default.js文件如下
function GetMac()

{

var clientIP="192.168.0.1";

//document.getElementById("Mac").value
=DemoMethods.GetCustomerMac(clientIP).value

alert(DemoMethods.GetCustomerMac
(clientIP).value);

}

  5.在某个Aspx页面放上一个html 的button在页面上中引用default.js :
lt;
script language="javascript"
src="default.js">
</script>

  在INPUT的onclick事件中加上
onclick="javascript:GetMac()"

lt;
INPUT style="Z-INDEX: 101; 
LEFT: 392px; POSITION: absolute;
TOP: 176px" type="button"

  value="客户端获取IP" onclick="javascript:GetMac();">

  6.在page页面的Page_Load事件中加上

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

{

// 在此处放置用户代码以初始化页面

Ajax.Utility.RegisterTypeForAjax
(typeof(AjaxSample.DemoMethods));

}

  注意:typeof(AjaxSample.DemoMethods)中,AjaxSample是命名空间,DemoMethods是要包含要调用方法的类,即上面第3步.新建类DemoMethods

7.修改Global.asax的Application_Start事件,设置Ajax的HandlerPath :

protected void Application_Start
(Object sender, EventArgs e)

{

Ajax.Utility.HandlerPath = "ajax";

}

  运行看看效果。是不是没有刷新就在服务器端取到客户端的MAC地址?

  需要注意的是:该版本的.net Ajax需要手工在中Global.asax加上Ajax.Utility.HandlerPath = "ajax"; 配置文件web.config必须加上HttpHandler的配置信息!

  该开发包的新版本还没有来得及体验,估计新版本中会方便一些,可能会去掉手动的设置Global.asax的Application_Start事件中加上Ajax.Utility.HandlerPath = "ajax";以及其他麻烦的设置!
.NET Ajax的无刷新技术实例详解


  下载一个.net Ajax开发包,该开发包包括ASP2.0和目前ASP1.1版使用的Ajax,详细地址参见http://ajax.schwarz-interactive.de/,接下来,开始。

  1. 新建一个项目,在引用中添加引用Ajax.dll,Ajax.dll位于下载的压缩包里面。

  2.建立HttpHandler,在web.config里面加上:

<configuration>

lt;
system.web>

lt;
httpHandlers>

lt;
add verb="POST,GET" 
path="ajax/*.ashx"
type="Ajax.PageHandlerFactory,
Ajax" />

lt;
/httpHandlers> 

<system.web>

lt;
/configuration>

  3.新建一个类DemoMethods,这个类实现获取客户端MAC地址:

using System;

using System.Web;

namespace AjaxSample

{

/**//// <summary>

/// Summary description for Methods.

/// </summary>

ublic class DemoMethods

{

[Ajax.AjaxMethod]

ublic 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();

}

}}

  4.写javascript,新建一个名为default.js文件如下

function GetMac()

{

var clientIP="192.168.0.1";

//document.getElementById("Mac").value
=DemoMethods.GetCustomerMac(clientIP).value

alert(DemoMethods.GetCustomerMac
(clientIP).value);

}

  5.在某个Aspx页面放上一个html 的button在页面上中引用default.js :

lt;
script language="javascript"
src="default.js">
</script>

  在INPUT的onclick事件中加上

onclick="javascript:GetMac()"

lt;
INPUT style="Z-INDEX: 101; 
LEFT: 392px; POSITION: absolute;
TOP: 176px" type="button"

  value="客户端获取IP" onclick="javascript:GetMac();">

  6.在page页面的Page_Load事件中加上

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

{

// 在此处放置用户代码以初始化页面

Ajax.Utility.RegisterTypeForAjax
(typeof(AjaxSample.DemoMethods));

}

  注意:typeof(AjaxSample.DemoMethods)中,AjaxSample是命名空间,DemoMethods是要包含要调用方法的类,即上面第3步.新建类DemoMethods

7.修改Global.asax的Application_Start事件,设置Ajax的HandlerPath :

protected void Application_Start
(Object sender, EventArgs e)

{

Ajax.Utility.HandlerPath = "ajax";

}

  运行看看效果。是不是没有刷新就在服务器端取到客户端的MAC地址?

  需要注意的是:该版本的.net Ajax需要手工在中Global.asax加上Ajax.Utility.HandlerPath = "ajax"; 配置文件web.config必须加上HttpHandler的配置信息!

  该开发包的新版本还没有来得及体验,估计新版本中会方便一些,可能会去掉手动的设置Global.asax的Application_Start事件中加上Ajax.Utility.HandlerPath = "ajax";以及其他麻烦的设置!