locked
Security error when downloading RSS in class WebClient RRS feed

  • Question

  • Hello, I am developing an application that need to consult multiple RSS and am having a problem that run in OutOfbrowser not happen, but if you run the browser is the error "Security Error". The error occurs when the feedback method OpenReadAsync WebClient class. Can anyone help me? The Code is the following:

    1            private void GetDescription(string search)
    2            {
    3                WebClient client = new WebClient();
    4                client.OpenReadCompleted += new OpenReadCompletedEventHandler(client_OpenReadCompleted);
    5                
    6                string url = "http://www.WWWWWWWWWWWW.com/feeds/WWWWWWW/" + search;
    7                client.OpenReadAsync(new Uri(url));
    8            }
    9    
    10           void client_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
    11           {
    12               if (e.Error == null)
    13               {                
    14                   XDocument doc = XDocument.Load(e.Result);
    15               }
    16            }
    
     

    The error occurs in the method client_OpenReadCompleted I've tried to create the clientaccesspolicy.xml as Tim Heuer writes in http://timheuer.com/blog/archive/2008/04/06/silverlight-cross-domain-policy-file-snippet-intellisense.aspx but not yet I succeeded. What I find strange is, if I use in Ouf Of Browser works.

    The Stacktrace error is

    [System.Security.SecurityException] = (System.Security.SecurityException: Security error. in System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse (IAsyncResult asyncResult) in System.Net.Browser.BrowserHttpWebRequest. <> c__DisplayClass5. b__4 (Object sendState) ...

    Thank you.

    I look back.

    Monday, June 28, 2010 10:34 PM

Answers

All replies

  • I've tried to create the clientaccesspolicy.xml as Tim Heuer writes in http://timheuer.com/blog/archive/2008/04/06/silverlight-cross-domain-policy-file-snippet-intellisense.aspx but not yet I succeeded
     

    Its a cross domain issue you required  clientaccesspolicy.xml. Please try to place the proper policy file and check again.

     

    What I find strange is, if I use in Ouf Of Browser works.

    The Silverlight version 4 runtime offers relaxed security policy checks for network applications that run as out-of browser applications with elevated trusted. Using this feature, an out-of-browser Silverlight application can be configured in its manifest as a trusted application that needs to run with elevated trust. The user is warned when trying to install a trusted application and must provide consent. If the user gives consent, the Silverlight trusted application is run within an expanded sandbox which allows it to access network and local resources that a normal Silverlight application is explicitly denied the ability to access for security reasons.

    More info here: http://msdn.microsoft.com/en-us/library/cc645032%28VS.95%29.aspx

    Tuesday, June 29, 2010 6:15 AM
  • Thanks !

    And What would be the proper policy for the operation? The file should be on the same level as the aspx page or the silverlight application?

     

    Tuesday, June 29, 2010 9:18 AM
  •  Please read again:http://timheuer.com/blog/archive/2008/04/06/silverlight-cross-domain-policy-file-snippet-intellisense.aspx

    "it needs to go in the ROOT of the domain.  This is important as it is not the application root, but the root web.  Even if your app is at foo.com/myapp, the policy file needs to be at foo.com/clientaccesspolicy.xml."

     If you can't get the snippet you can use the sample policy file here: http://msdn.microsoft.com/en-us/library/cc645032%28VS.95%29.aspx

    Tuesday, June 29, 2010 12:40 PM
  • As I said earlier, I implemented clientaccesspolicy.xml see the file's code file:

    <?xml version="1.0" encoding="utf-8"?>
    <access-policy>
      <cross-domain-access>
        <policy>
          <allow-from>
            <domain uri="*"/>
          </allow-from>
          <grant-to>
            <resource path="/" include-subpaths="true"/>
          </grant-to>
        </policy>
      </cross-domain-access>
    </access-policy>


    See the picture of my solution.

    http://djonatas.net/Capture.PNG


    When I run with F5 continues with the error ...
    clientaccesspolicy.xml the file is marked with the option to Copy to Output Directory = Copy always
    appreciate the strong support
     
     
    Tuesday, June 29, 2010 11:13 PM
  • Hi,

        You may use a fiddler to check the location where your client app is requesting the CrossDomainPolicy.xml file.

        And to see if the request is correctly responsed.

    Best Regards

    Wednesday, June 30, 2010 2:01 AM
  • Hello my friends, after much struggle I gave up and decided to use only in order Out Of Browser
    Thursday, July 8, 2010 1:34 AM