简体   繁体   English

如何使用ASP Classic检查用户/页面是否已连接到Internet以进行脱机开发?

[英]How to Check if a User/Page is Connected to the Internet with ASP Classic for Offline Development?

I'm fairly familiar with the language but this concept is a puzzle to me. 我对这种语言相当熟悉,但是这个概念对我来说是一个难题。 I am wanting ot check if the server on which the script is running can access the internet for development so let's say if I am just working on the site offline on my own server with everything I need but internet access. 我要检查运行脚本的服务器是否可以访问Internet进行开发,所以可以说,如果我只是在脱机状态下在自己的服务器上使用Internet进行访问,那么我需要的一切。 Catch my drift? 赶上我的漂移? Thank you. 谢谢。

You can try and ping a site like this: (not tested) 您可以尝试对这样的站点执行ping操作:(未测试)

url = "www.google.com"
Set objWShell = CreateObject("WScript.Shell")
Set objCmd = objWShell.Exec("ping " & url)
strPingResult = objCmd.StdOut.Readall()
set objCmd = nothing 
set objWShell = nothing

strStatus = "offline"

if InStr(strPingResult,"TTL=") > 0 then strStatus = "online"

response.write url & " is " & strStatus

response.write ".<br>" & replace(strPingResult,vbCrLf,"<br>")

不知道我是否理解正确,但是您可以为此使用Session对象/ Global.asa文件> Session_OnStartSession_OnEnd

Check out the answer I posted on this very similar question: 看看我在这个非常相似的问题上发布的答案:

How to check the availability of internet in classic asp? 如何检查经典ASP中的互联网可用性?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM