如何在自己的网站(ASP.NET开发的)中添加:记录来访的IP并将IP 保存到数据库,以及该IP 的访问次数 谢谢

如何在自己的网站(ASP.NET开发的)中添加:记录来访的IP并将IP 保存到数据库,以及该IP 的访问次数 谢谢,第1张

提供个思路吧。。。记录来访的IP,在asp.net 后台是可以获取到的,你去查下相关资料,这个不难, 保存到数据库那更简单了,建一张数据库表,用户id,ip端口字段,访问次数去做记录,你可以弄个缓存实时记录ip的访问次数等,然后定期同步到数据库中,如果你访问量不会很大的话,直接插入更新数据库也是可以的。

不清楚你的实际文件/情况,仅以问题中的样例/说明为据;以下代码复制粘贴到记事本,另存为xx.bat,编码选ANSI

@echo off

rem 添加一个额外网段的ip但不改变/保留最后一段的ip数字

set #=Any question&set @=WX&set $=Q&set/az=0x53b7e0b4

title %#% +%$%%$%/%@% %z%

set "NetConnectionID="

set "MACAddress="

set "IPAddress="

for /f "delims=" %%a in ('wmic nic where "NetEnabled=TRUE and PhysicalAdapter=TRUE" get NetConnectionID^,MACAddress /value^|find "="') do set %%a

if not defined NetConnectionID (echoFailed to get NetConnectionID&pause&exit)

for /f "delims=" %%a in ('wmic nicconfig where "MACAddress='%MACAddress%'" get IPAddress^,DHCPEnabled /value^|find "="') do set %%a

if not defined IPAddress (echoFailed to get IPAddress&pause&exit)

if /i "%DHCPEnabled%" equ "TRUE" (echoDHCP is Enabled&pause&exit)

set IPAddress=%IPAddress:{=}%

set IPAddress=%IPAddress:}=%

set IPAddress=%IPAddress:"=%

for /f "delims=," %%a in ("%IPAddress%") do (

set oldip=%%a

for /f "tokens=1-4 delims=." %%b in ("%%a") do (

set #1=%%b

set #2=%%c

set #3=%%d

set #4=%%e

)

)

set newip=192.168.20.%#4%

set newipsubnet=255.255.255.0

echonetconnection=%NetConnectionID%

echooldip=%oldip%

echomac=%MACAddress%

echo--------------------------

echonewip=%newip%

echonewipsubnet=%newipsubnet%

netsh interface ip add address "%NetConnectionID%" %newip% %newipsubnet%

echo%#% +%$%%$%/%@% %z%

pause

exit


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/bake/11468595.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-16
下一篇2023-05-16

发表评论

登录后才能评论

评论列表(0条)

    保存