能够获在C#取访问的页面的响应时间,是不是能够正常访问.
是怎么一个思路的啊?
谢谢
是怎么一个思路的啊?
谢谢
解决方案 »
- C#中linklabel的显示问题
- 加急!!!!string型怎么转换为int型呀???
- 多线程的希奇古怪的问题!(高手请进,在线等,急)
- 用C#做c/s结构的软件怎样解决数据冲突问题?
- API函数ReadFile调用后,用GetLastWin32Error捕获错误提示为“函数不正确”,请问是什么原因?
- GDI+ 的问题
- Zedgraph画图表的库,怎么才能读取出XY坐标的数据
- DataGridView.Rows.Add抛出异常了,为什么呢?
- 我中了Backdoor.Trojan病毒,怎么医治?
- 在WIN2000下如何用C#改变系统日期时间--急(在线等待)
- 如何让messagebox.show只引出一个对话框?
- 关于C#中的接口
public static bool GetPageRight(String url, WebProxy proxyObject, out string ret_str)
{
string proxy_str="null";
ret_str=url+":未知错误";
try
{
// Creates an HttpWebRequest for the specified URL.
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url);
myHttpWebRequest.Proxy =proxyObject;
if(proxyObject.Address!=null)proxy_str=proxyObject.Address.ToString();
// Sends the HttpWebRequest and waits for a response.
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
if (myHttpWebResponse.StatusCode == HttpStatusCode.OK)
ret_str=":返回正确,通过代理: "+proxy_str+" : "+url+" :返回代码为 OK 且返回状态描述为: "+myHttpWebResponse.StatusDescription;
// Releases the resources of the response.
myHttpWebResponse.Close();
return true;
}
catch(WebException e)
{
ret_str=":出现Web错误,通过代理: "+proxy_str+" : "+url+" :发生Web异常! 错误代码如下 : "+e.Status.ToString();
}
catch(Exception e)
{
ret_str=":出现未知错误,通过代理: "+proxy_str+" : "+url+" :错误代码如下 : "+e.Message;
} return false;
}