WebClient security error when accessing the world of warcraft armoury

Posted by user348446 on Stack Overflow See other posts from Stack Overflow or by user348446
Published on 2010-05-24T20:43:01Z Indexed on 2010/05/24 21:11 UTC
Read the original article Hit count: 611

Filed under:
|
|
|
|

Hello World,

I am trying to piece together a solution to a problem. Basically I am using Silverlight 4 with C# 4.0 to access the world of warcraft armoury. If anyone has done this - please oh please provide the working .net 4.0 code.

The code I am attempting to run is (e.Error contains a securtiy error):

private void button10_Click(object sender, RoutedEventArgs e)
        {
            string url = @"http://eu.wowarmory.com/guild-info.xml?r=Eonar&n=Gifted and Talented"; 
            WebClient wc = new WebClient();

            // HOW DO I ADD A USER AGENT STRING (RESPONSE MAY VARY (I.E. HTML VS XML) IF PAGE THINKS CALL IS NOT CAPABABLE OF SUPPORTING XML TRANSFORMATIONS) 
            //wc.ResponseHeaders["User-Agent"] = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0)";

            wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted);
            wc.DownloadStringAsync(new Uri(url));    
        }

        void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                string result = e.Result;

                XDocument ArmouryXML = XDocument.Parse(result);

                ShowGuildies(ArmouryXML);
            }
            else
            {
                MessageBox.Show("Something is complaining about security but not sure what!");
            }
        } 

Notes:

  1. C# 4.0
  2. The armoury is an XML file - but i believe it reverts to html should the request not be from a browser that supports XML transformation. But i don't think I am getting this far.
  3. The armoury has a cross domain policy file on it - this may be the cause of the error (not sure!
  4. I have uploaded to a production server
  5. I am testing it locally using IIS website
  6. I am going insane!
  7. Websites have made the suggestion that this problem can be overcome by creating a WebProxy - but I haven't the first clue how to do this.

It would be great if someone could take on this challenge and show us all that it is possible. I'd prefer a non-proxy solution first, then try a proxy.

The error details:

e.Error = {System.Security.SecurityException ---> System.Security.SecurityException: Security error. at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult) at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClass5.

Any intelligent master coders out there who can solve this in their sleep?

Thanks if you can! Pass this on to someone who can if you can't. If you know someone who can't, don't pass it to them, but if you know someone can't then presumedly you know how to solve it and would encourage you to give it a go!

Cheers! Dan.

© Stack Overflow or respective owner

Related posts about c#

Related posts about Silverlight