下面开始吧:
首先写一个简单的前台代码:
复制代码 代码如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div style="text-align: left">
<strong><span style="font-size: 14pt">欢迎光临爱智旮旯的博客!</span><br />
</strong><span style="font-size: 10pt; color: #ff0000">注:每台计算机只可以领取一个帐号<br />
</span>
<asp:Button ID="getNamePass" runat="server" OnClick="getNamePass_Click" Text="领取帐号密码" /> <br />
<asp:Label ID="labName" runat="server"></asp:Label><br />
<asp:Label ID="labPass" runat="server"></asp:Label><br />
</div>
</form>
</body>
</html>
再来写一个后台代码,备注已经说的比较清楚,这里不多说了!
复制代码 代码如下:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text.RegularExpressions;
using System.Diagnostics;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
labName.Text = labPass.Text = "";
}
protected void getNamePass_Click(object sender, EventArgs e)
{
//获取客户端的IP地址
string IP = Request.UserHostAddress;
//创建字符串变量
string dirResults = "";
//创建ProcessStartInfo对象表示启动进程时使用的一组值
ProcessStartInfo psi = new ProcessStartInfo();
//创建Process对象使您能够启动和停止本地系统进程
Process proc = new Process();
//设置要启动的应用程序或文档
psi.FileName = "nbtstat";
//设置不从Process.StandardInput流中读取输入
psi.RedirectStandardInput = false;
//设置要输出写入 Process.StandardOutput流
psi.RedirectStandardOutput = true;
//设置启动的应用程序中的一组命令参数
psi.Arguments = "-A " + IP;
//设置从可执行文件创建进程
psi.UseShellExecute = false;
//设置启动进程
proc = Process.Start(psi);
//获取StandardOutput输出流
dirResults = proc.StandardOutput.ReadToEnd();
//设置Process 组件无限期地等待关联进程退出
proc.WaitForExit();
//替换掉StandardOutput输出流中的"/r,/n,/t"
dirResults = dirResults.Replace("\r", "").Replace("\n", "").Replace("\t", "");
//设置正则表达式
Regex reg = new Regex("MAC[ ]{0,}Address[ ]{0,}=[ ]{0,}(?<key>((.)*?))MAC", RegexOptions.IgnoreCase | RegexOptions.Compiled);
//向获取的StandardOutput输出流添加"MAC"字符串
dirResults = dirResults + "MAC";
//获取Cookie
HttpCookie oldCookie = Request.Cookies["netCard"];
//获取正则表达式中的匹配项
Match mc = reg.Match(dirResults);
//获取网卡号去除掉“-”符合
string networkCard = mc.Groups["key"].Value.Replace("-", "");
//判断Cookie是否为空
if (oldCookie == null)
{
//判断是否符合正则表达式的要求
if (mc.Success)
{
//显示帐号
labName.Text = "您的帐号为:" + networkCard;
//显示密码
labPass.Text = "您的密码为:1234";
//创建Cookie对象
HttpCookie newCookie = new HttpCookie("netCard");
//设置Cookie的有效时间
newCookie.Expires = DateTime.MaxValue;
//添加Cookie中的值
newCookie.Values.Add("numberCard", networkCard);
//将Cookie添加到Cookie集合中
Response.Cookies.Add(newCookie);
}
else
{
RegisterStartupScript("", "<script>alert( '您没有联网!');</script>");
}
}
else
{
//获取Cookie中的网卡号
string numberCard = oldCookie.Values["numberCard"];
//判断Cookie中的网卡号是否和获取到的网卡号一致
if (numberCard.Trim() == networkCard.Trim())
{
RegisterStartupScript("", "<script>alert('很抱歉!您的计算机已领取过帐号。')</script>");
}
else
{
//判断是否符合正则表达式的要求
if (mc.Success)
{
//显示帐号
labName.Text = "您的帐号为:" + networkCard;
//显示密码
labPass.Text = "您的密码为:1234";
//修改Cookie中的值
oldCookie.Values.Set("numberCard", networkCard);
//将Cookie添加到Cookie集合中
Response.Cookies.Add(oldCookie);
}
else
{
RegisterStartupScript("", "<script>alert( '您没有联网!');</script>");
}
}
}
}
}
首先写一个简单的前台代码:
复制代码 代码如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div style="text-align: left">
<strong><span style="font-size: 14pt">欢迎光临爱智旮旯的博客!</span><br />
</strong><span style="font-size: 10pt; color: #ff0000">注:每台计算机只可以领取一个帐号<br />
</span>
<asp:Button ID="getNamePass" runat="server" OnClick="getNamePass_Click" Text="领取帐号密码" /> <br />
<asp:Label ID="labName" runat="server"></asp:Label><br />
<asp:Label ID="labPass" runat="server"></asp:Label><br />
</div>
</form>
</body>
</html>
再来写一个后台代码,备注已经说的比较清楚,这里不多说了!
复制代码 代码如下:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text.RegularExpressions;
using System.Diagnostics;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
labName.Text = labPass.Text = "";
}
protected void getNamePass_Click(object sender, EventArgs e)
{
//获取客户端的IP地址
string IP = Request.UserHostAddress;
//创建字符串变量
string dirResults = "";
//创建ProcessStartInfo对象表示启动进程时使用的一组值
ProcessStartInfo psi = new ProcessStartInfo();
//创建Process对象使您能够启动和停止本地系统进程
Process proc = new Process();
//设置要启动的应用程序或文档
psi.FileName = "nbtstat";
//设置不从Process.StandardInput流中读取输入
psi.RedirectStandardInput = false;
//设置要输出写入 Process.StandardOutput流
psi.RedirectStandardOutput = true;
//设置启动的应用程序中的一组命令参数
psi.Arguments = "-A " + IP;
//设置从可执行文件创建进程
psi.UseShellExecute = false;
//设置启动进程
proc = Process.Start(psi);
//获取StandardOutput输出流
dirResults = proc.StandardOutput.ReadToEnd();
//设置Process 组件无限期地等待关联进程退出
proc.WaitForExit();
//替换掉StandardOutput输出流中的"/r,/n,/t"
dirResults = dirResults.Replace("\r", "").Replace("\n", "").Replace("\t", "");
//设置正则表达式
Regex reg = new Regex("MAC[ ]{0,}Address[ ]{0,}=[ ]{0,}(?<key>((.)*?))MAC", RegexOptions.IgnoreCase | RegexOptions.Compiled);
//向获取的StandardOutput输出流添加"MAC"字符串
dirResults = dirResults + "MAC";
//获取Cookie
HttpCookie oldCookie = Request.Cookies["netCard"];
//获取正则表达式中的匹配项
Match mc = reg.Match(dirResults);
//获取网卡号去除掉“-”符合
string networkCard = mc.Groups["key"].Value.Replace("-", "");
//判断Cookie是否为空
if (oldCookie == null)
{
//判断是否符合正则表达式的要求
if (mc.Success)
{
//显示帐号
labName.Text = "您的帐号为:" + networkCard;
//显示密码
labPass.Text = "您的密码为:1234";
//创建Cookie对象
HttpCookie newCookie = new HttpCookie("netCard");
//设置Cookie的有效时间
newCookie.Expires = DateTime.MaxValue;
//添加Cookie中的值
newCookie.Values.Add("numberCard", networkCard);
//将Cookie添加到Cookie集合中
Response.Cookies.Add(newCookie);
}
else
{
RegisterStartupScript("", "<script>alert( '您没有联网!');</script>");
}
}
else
{
//获取Cookie中的网卡号
string numberCard = oldCookie.Values["numberCard"];
//判断Cookie中的网卡号是否和获取到的网卡号一致
if (numberCard.Trim() == networkCard.Trim())
{
RegisterStartupScript("", "<script>alert('很抱歉!您的计算机已领取过帐号。')</script>");
}
else
{
//判断是否符合正则表达式的要求
if (mc.Success)
{
//显示帐号
labName.Text = "您的帐号为:" + networkCard;
//显示密码
labPass.Text = "您的密码为:1234";
//修改Cookie中的值
oldCookie.Values.Set("numberCard", networkCard);
//将Cookie添加到Cookie集合中
Response.Cookies.Add(oldCookie);
}
else
{
RegisterStartupScript("", "<script>alert( '您没有联网!');</script>");
}
}
}
}
}
标签:
MAC
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
桃源资源网 Design By www.nqtax.com
暂无“asp.net根据计算机MAC地址限定每台机子只能领取一次账号”评论...
《魔兽世界》大逃杀!60人新游玩模式《强袭风暴》3月21日上线
暴雪近日发布了《魔兽世界》10.2.6 更新内容,新游玩模式《强袭风暴》即将于3月21 日在亚服上线,届时玩家将前往阿拉希高地展开一场 60 人大逃杀对战。
艾泽拉斯的冒险者已经征服了艾泽拉斯的大地及遥远的彼岸。他们在对抗世界上最致命的敌人时展现出过人的手腕,并且成功阻止终结宇宙等级的威胁。当他们在为即将于《魔兽世界》资料片《地心之战》中来袭的萨拉塔斯势力做战斗准备时,他们还需要在熟悉的阿拉希高地面对一个全新的敌人──那就是彼此。在《巨龙崛起》10.2.6 更新的《强袭风暴》中,玩家将会进入一个全新的海盗主题大逃杀式限时活动,其中包含极高的风险和史诗级的奖励。
《强袭风暴》不是普通的战场,作为一个独立于主游戏之外的活动,玩家可以用大逃杀的风格来体验《魔兽世界》,不分职业、不分装备(除了你在赛局中捡到的),光是技巧和战略的强弱之分就能决定出谁才是能坚持到最后的赢家。本次活动将会开放单人和双人模式,玩家在加入海盗主题的预赛大厅区域前,可以从强袭风暴角色画面新增好友。游玩游戏将可以累计名望轨迹,《巨龙崛起》和《魔兽世界:巫妖王之怒 经典版》的玩家都可以获得奖励。