Imports System.Text
Imports System.Net
Imports System.IO Public Shared Function GetDate(ByVal strUrl As String) As String
Dim html As String = ""
Try
Dim resp As HttpWebResponse
Dim req As HttpWebRequest = CType(HttpWebRequest.Create(strUrl), HttpWebRequest)
req.Timeout = 250000
resp = CType(req.GetResponse(), HttpWebResponse)
Dim sr As StreamReader = New StreamReader(resp.GetResponseStream(), System.Text.Encoding.Default)
html = "访问成功返回代码如下:" & sr.ReadToEnd()
Catch ex As Exception
html = "错误:" & ex.Message
End Try
Return html
End Function
Imports System.Net
Imports System.IO Public Shared Function GetDate(ByVal strUrl As String) As String
Dim html As String = ""
Try
Dim resp As HttpWebResponse
Dim req As HttpWebRequest = CType(HttpWebRequest.Create(strUrl), HttpWebRequest)
req.Timeout = 250000
resp = CType(req.GetResponse(), HttpWebResponse)
Dim sr As StreamReader = New StreamReader(resp.GetResponseStream(), System.Text.Encoding.Default)
html = "访问成功返回代码如下:" & sr.ReadToEnd()
Catch ex As Exception
html = "错误:" & ex.Message
End Try
Return html
End Function
解决方案 »
- 控件的使用问题navBarControl控件,求大神关注
- 串口异常信息提示:设备没有连接的可能情况是什么?
- System.Net.HttpWebRequest.GetResponse 读取source的问题
- DotNetSpeech中实现中文女声发音
- 用TrimEnd(',')截断最后一个逗号报错
- 用C#编的WIN应用程序,如何在DOS下运行
- 200分求教:用VS2003连接Solaris下的Sybase数据库的疑问!
- 用installutil.exe安装服务不成功
- 写入数据
- dPrice += Convert.ToDecimal(sdr[4].ToString()) * Convert.ToDecimal(sdr[5].ToString());System.FormatException: 输入字符串的格
- 怎么给webform换skin?????
- 用c#写了个俄罗斯方块。想发到网上。应该会对一些新手有点帮助吧。
using System.Net;string url=".........";//网址
try
{
Uri uri=new Uri(url);
System.Net.Dns.Resolve(uri.Host);
}
catch(Exception ex)
{
string msg=ex.Message;
}另上面的转换为c#如下:
public string GetDate(string strUrl)
{
string html="";
try
{
System.Net.HttpWebRequest req=System.Net.HttpWebRequest.Create(strUrl);
req.Timeout =250000;
System.Net.HttpWebResponse resp=req.GetResponse();
System.IO.StreamReader sr=new System.IO.StreamReader(resp.GetResponseStream(),System.Text.Encoding.Default);
html ="访问成功返回代码如下:" & sr.ReadToEnd();
}
catch(Exception ex)
{
html ="错误:" & ex.Message;
}
return html;
}