请问大家:怎么判断一个一个Http(rtsp/mms)连接URL是否有效呢 谢谢大家了 公司要做个监控网络电台地址功能,发愁中!!!
解决方案 »
- js判断邮箱格式
- 如何将内网的网站使用www.abc***.com方式替换原有IP访问方式。
- select * from authors where au_id is not null 存储过程如何写?
- ***[两星菜鸟--冰戈]升星散分、给大家个承诺、另带问个问题***
- 麻烦大家帮我看看 关于IIS自定义错误 的问题。 ---100分求解!
- 请教,怎样用IE通过TCP连接WEB SERVER?有人知道吗?
- Help me !Give you high scores
- 噢,我的SQL语言,HELP!!!
- 浏览器兼容性问题
- 关于petshop中的搜索
- GridView编辑列遇到的问题……
- 正则表达式匹配
<!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> <title>Untitled Page</title> <script type="text/javascript" src="../JS/jQuery/jquery.js"></script>
<script type="text/javascript"> function NetPing() { $.ajax({ type: "GET", cache: false, url: "http://www.163.com/index.html", data: "", success: function(){ Done(1); }, error:function(){ Done(0); } }); } function Done(rel) { if(rel==1) { document.getElementById('Text1').value="网络已连接"; } else { document.getElementById('Text1').value="网络未连接"; } } function Button1_onclick() { NetPing(); }
</script>
</head><body> <input id="Button1" type="button" value="探测" onclick="return Button1_onclick()" /> <input id="Text1" type="text" /></body></html>
而不是楼上说的http://www.163.com/index.html 链接
try
{
HttpWebRequest request;
HttpWebResponse response;
string strResult = "";
request = (HttpWebRequest)HttpWebRequest.Create(url);
request.Timeout = _iSetTimeOut;
request.KeepAlive = false;
request.ServicePoint.Expect100Continue = false;
request.ServicePoint.UseNagleAlgorithm = false;
request.ReadWriteTimeout = _iSetTimeOut;
request.Method = "GET";
request.Accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*";
request.UserAgent = " Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727;)";
response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{
return true;
}
}
catch (Exception ex) { return false; }