婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > asp.net根據(jù)計算機MAC地址限定每臺機子只能領(lǐng)取一次賬號

asp.net根據(jù)計算機MAC地址限定每臺機子只能領(lǐng)取一次賬號

熱門標簽:陜西人工外呼系統(tǒng)哪家好 地圖標注多個行程 浙江外呼系統(tǒng)怎么安裝 廈門商鋪地圖標注 銅川小型外呼系統(tǒng)運營商 山西防封卡電銷卡套餐 海外地圖標注門市標 上海楊浦怎么申請申請400電話 云南外呼電銷機器人系統(tǒng)
下面開始吧:
首先寫一個簡單的前臺代碼:
復(fù)制代碼 代碼如下:

%@ 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">注:每臺計算機只可以領(lǐng)取一個帳號br />
/span>
asp:Button ID="getNamePass" runat="server" OnClick="getNamePass_Click" Text="領(lǐng)取帳號密碼" />nbsp;br />
asp:Label ID="labName" runat="server">/asp:Label>br />
asp:Label ID="labPass" runat="server">/asp:Label>br />
/div>
/form>
/body>
/html>

再來寫一個后臺代碼,備注已經(jīng)說的比較清楚,這里不多說了!
復(fù)制代碼 代碼如下:

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;
//創(chuàng)建字符串變量
string dirResults = "";
//創(chuàng)建ProcessStartInfo對象表示啟動進程時使用的一組值
ProcessStartInfo psi = new ProcessStartInfo();
//創(chuàng)建Process對象使您能夠啟動和停止本地系統(tǒng)進程
Process proc = new Process();
//設(shè)置要啟動的應(yīng)用程序或文檔
psi.FileName = "nbtstat";
//設(shè)置不從Process.StandardInput流中讀取輸入
psi.RedirectStandardInput = false;
//設(shè)置要輸出寫入 Process.StandardOutput流
psi.RedirectStandardOutput = true;
//設(shè)置啟動的應(yīng)用程序中的一組命令參數(shù)
psi.Arguments = "-A " + IP;
//設(shè)置從可執(zhí)行文件創(chuàng)建進程
psi.UseShellExecute = false;
//設(shè)置啟動進程
proc = Process.Start(psi);
//獲取StandardOutput輸出流
dirResults = proc.StandardOutput.ReadToEnd();
//設(shè)置Process 組件無限期地等待關(guān)聯(lián)進程退出
proc.WaitForExit();
//替換掉StandardOutput輸出流中的"/r,/n,/t"
dirResults = dirResults.Replace("\r", "").Replace("\n", "").Replace("\t", "");
//設(shè)置正則表達式
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);
//獲取網(wǎng)卡號去除掉“-”符合
string networkCard = mc.Groups["key"].Value.Replace("-", "");
//判斷Cookie是否為空
if (oldCookie == null)
{
//判斷是否符合正則表達式的要求
if (mc.Success)
{
//顯示帳號
labName.Text = "您的帳號為:" + networkCard;
//顯示密碼
labPass.Text = "您的密碼為:1234";
//創(chuàng)建Cookie對象
HttpCookie newCookie = new HttpCookie("netCard");
//設(shè)置Cookie的有效時間
newCookie.Expires = DateTime.MaxValue;
//添加Cookie中的值
newCookie.Values.Add("numberCard", networkCard);
//將Cookie添加到Cookie集合中
Response.Cookies.Add(newCookie);
}
else
{
RegisterStartupScript("", "script>alert( '您沒有聯(lián)網(wǎng)!');/script>");
}
}
else
{
//獲取Cookie中的網(wǎng)卡號
string numberCard = oldCookie.Values["numberCard"];
//判斷Cookie中的網(wǎng)卡號是否和獲取到的網(wǎng)卡號一致
if (numberCard.Trim() == networkCard.Trim())
{
RegisterStartupScript("", "script>alert('很抱歉!您的計算機已領(lǐng)取過帳號。')/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( '您沒有聯(lián)網(wǎng)!');/script>");
}
}
}
}
}
您可能感興趣的文章:
  • ASP.NET MVC5驗證系列之服務(wù)端驗證
  • ASP.NET MVC+EF在服務(wù)端分頁使用jqGrid以及jquery Datatables的注意事項
  • ASP.NET獲取真正的客戶端IP地址的6種方法
  • asp.net 從客戶端中檢測到有潛在危險的 Request.Form 值錯誤解
  • asp.net(C#)中給控件添加客戶端js事件的方法
  • asp.net 客戶端瀏覽器緩存的Http頭介紹
  • 設(shè)置ASP.NET頁面不被緩存(客戶端/服務(wù)器端取消緩存方法)
  • ASP.net中獲取客戶端參數(shù)操作系統(tǒng)信息
  • asp.net實現(xiàn)獲取客戶端詳細信息
  • ASP.NET簡單獲取服務(wù)端和客戶端計算機名稱的方法

標簽:萊蕪 西雙版納 信陽 孝感 朔州 許昌 常州 自貢

巨人網(wǎng)絡(luò)通訊聲明:本文標題《asp.net根據(jù)計算機MAC地址限定每臺機子只能領(lǐng)取一次賬號》,本文關(guān)鍵詞  asp.net,根據(jù),計算機,MAC,地址,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《asp.net根據(jù)計算機MAC地址限定每臺機子只能領(lǐng)取一次賬號》相關(guān)的同類信息!
  • 本頁收集關(guān)于asp.net根據(jù)計算機MAC地址限定每臺機子只能領(lǐng)取一次賬號的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 隆昌县| 上林县| 呈贡县| 桦川县| 旌德县| 桂平市| 安吉县| 南木林县| 睢宁县| 镇远县| 黔南| 屏南县| 桃江县| 洪湖市| 恩施市| 阳山县| 安乡县| 茂名市| 绥棱县| 洞口县| 高邑县| 蒙山县| 时尚| 鹤峰县| 咸阳市| 温宿县| 枣阳市| 白山市| 合江县| 兴海县| 纳雍县| 台东市| 康定县| 湖北省| 光泽县| 霍林郭勒市| 嫩江县| 罗山县| 平江县| 平遥县| 临猗县|