我正在尝试从 Silverlight 中的网页获取源代码。
这是我的代码
WebClient wc = new WebClient();
wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(WebClient_DownloadStringCompleted);
wc.DownloadStringAsync(new Uri("http://ip-whois-lookup.com/lookup.php?ip=19.118.245.124"));
void WebClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error == null)
{
Mytext.Text = e.Result.ToString();
}
else
Mytext.Text = e.Error.ToString();
}
这是我的错误。
System.Security.SecurityException ---> System.Security.SecurityException: Security error.
at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClassa.<EndGetResponse>b__9(Object sendState)
at System.Net.Browser.AsyncHelper.<>c__DisplayClass4.<BeginOnUI>b__0(Object sendState)
--- End of inner exception stack trace ---
at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.Net.WebClient.GetWebResponse(WebRequest request, IAsyncResult result)
at System.Net.WebClient.DownloadBitsResponseCallback(IAsyncResult result)
相同 url 的相同原理适用于 ac# 控制台应用程序
string htmlContent = new System.Net.WebClient().DownloadString("http://ip-whois-lookup.com/lookup.php?ip=19.118.245.124");
我正在寻找的是能够使用我选择的任何 ip 更改该 url 中的 ip 并获取该页面的源代码。
在 silverlight 中给出错误的相同代码适用于其他网站:例如:http ://tcpiputils.com/browse/ip-address/79.118.20.240、http: //livescore.com,但也不适用于 google。 com,也许还有其他人。