Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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
 }
share|improve this question
    
what error does it generates –  Muhammad Raja Feb 14 '13 at 16:53
add comment

1 Answer 1

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:

share|improve this answer
    
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 Feb 14 '13 at 20:00
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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