0

I am using following code in a Web Part to read Rss (atom). Same Web Part works in Farm Solution but generates error (don't know what) in a Sandbox solution.

 WebClient wc = new WebClient();
 wc.Credentials = new NetworkCredential("myuserName", "myPassword");

IEnumerable<myClass> feeds = null;
using (System.IO.Stream stream = wc.OpenRead(myfeed))
        {
            XDocument d = XDocument.Load(stream);
            XNamespace ns = XNamespace.Get("http://www.w3.org/2005/Atom");

            feeds = d.Root.Descendants(ns + "entry").Select(e =>
                new myClass
                {
                    Title = e.Element(ns + "title").Value,
                    Description = e.Element(ns + "summary").Value,
                    Link = e.Element(ns + "link").Value
                });
        }

 foreach (Rss item in feeds)
 {
     //render items
 }
1
  • what error does it generates Commented Feb 14, 2013 at 16:53

1 Answer 1

2

Most likely, it happens bacause it is impossible to "Create a Web Part that interacts with a Web service or a Windows Communication Foundation (WCF) service." in sandboxed solutions.

As a workaround you can create full-trust proxy.

Some links which could be usefull:

1
  • thank you for your answer, but you have to put a full trusted proxy into GAC which I am not allowed at all to do it.
    – user12955
    Commented Feb 14, 2013 at 20:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.