日期:2014-05-17 浏览次数:20879 次
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Model;
using Bll;
using System.Net;
public partial class websource : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (UrlIsExist("http://121.12.101.130/play/2DCF09326791E4336F0EA0C504BAD013BED62F47.flv"))//视频存在为什么显示不存在
{
Response.Write("存在");
}
else
{
Response.Write("不存在");
}
}
private bool UrlIsExist(String url)
{
System.Uri u = null;
try
{
u = new Uri(url);
}
catch { return false; }
bool isExist = false;
System.Net.HttpWebRequest r = System.Net.HttpWebRequest.Create(u) as System.Net.HttpWebRequest;
r.Method = "HEAD";
try
{
System.Net.HttpWebResponse s = r.GetResponse() as System.Net.HttpWebResponse;
if (s.StatusCode == System.Net.HttpStatusCode.OK)
{
isExist = true;
}
}
catch (System.Net.WebException x)
{
try
{
isExist = ((x.Response as System.Net.HttpWebResponse).StatusCode != System.Net.HttpStatusCode.NotFound);