SilverlightのWebページからソースコードを取得しようとしています。
これは私のコードです
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");
私が探しているのは、そのURLのIPを自分が選択した任意のIPで変更し、そのページのソースコードを取得できるようにすることです。
Silverlightでエラーを発生させる同じコードは、他のWebサイトでも機能します。例:http://tcpiputils.com/browse/ip-address/79.118.20.240、http://livescore.com、Googleでは機能しません。 comと多分他の人。