Load rss (xml) with Linq to XML on medium trust hosting

by Pieter Brinkman 26. November 2008 05:39

For a new project I needed to implement show data from RSS. The site will be hosted on a shared hosting environment with medium trust.

I load the rss with the following code:

XElement rssFeed = XElement.Load("[REPLACE WITH URL TO RSS]");
var posts = from item in rssFeed.Descendants("item")
                  select new
                  {
                       Title = item.Element("title").Value,
                       Description = item.Element("description").Value
                  };


This normally works fine for me... But apparently not with medium trust :-(! I got the following error.

Security Exception

Description: The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.


After reading a bit and playing with the web.config setting <TRUST /> I found the solution. The solution is putting a ".*" in the originUrl parameter of the trust node.

<trust level="Medium" originUrl=".*" />


So an easy solution for a annoying problem what took me to much time. So I hope this post will help somebody out there :-)

Categories: ASP.Net | Linq

200.000 Guids generated.

by Pieter Brinkman 24. November 2008 07:09

This weekend it happened the 200.000th guid has been generated on NewGuid.Net!! A success I never expected to happen :-)

 Most of the guids are generated by the IGoogle widget a must for every developer ;-)

Tags:
Categories:

Blog update

by Pieter Brinkman 23. November 2008 07:04
I updated the blog to BlogEnginge.Net 1.4.5. Changed the design and added some widgets.
Categories:

Portofolio: GetFreeWallpapers.net

by Pieter Brinkman 17. November 2008 03:50

Project description:

When trying to find a way to get my hosting expenses covered I started a Wallpaper-site (pretty lame, but still). At this moment I was playing with Linq and wanted to do some with Linq to Objects. At this moment the site creates his own navigation and image view with Linq to Object based on the file-system.

Used technologies:

  • Asp.Net 3.5 
  • Linq to Objects
  • Asp.Net Cache
Categories: Portfolio