![]() |
|
|
Welcome to the { mindfrost82.com } forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
Why i am getting System.Security exception with RSS feed code
I am using the System. ServiceModel.Syndication and linq to creat an RSS
Feed. Everything works fine locally but remotely i get the following error. Is adjusting the trust level the only way around this or can add some attribute to the class or is there another option. Trust level adjusting not an option since on shared hosting. The code for the rss feed folows the error message. Thanks Ashok 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.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. Public Class LinqToRss Private HttpCon As HttpContext = HttpCon.Current Private Cache As New Cache Public Function WriteRss() As String Dim articleslinq As New ArticlesLINQDataContext Dim ArticleQuery = From a In articleslinq.Articles Select a.ArticleID, a.ArticleSummary, a.ArticleTitle, a.DatePublished, a.ArticleText, a.IsActive Where IsActive = "Active" Order By DatePublished Descending HttpCon.Response.Buffer = False HttpCon.Response.Clear() HttpCon.Response.ContentType = "application/xml" Using XWriter = XmlWriter.Create(HttpCon.Response.OutputStream) Dim SyndFeed As New SyndicationFeed SyndFeed = New SyndicationFeed("RiderDesign.com Articles", "The latest ASP.NET articles and news from RiderDesign.com.", New Uri("http://www.RiderDesign.com/rss/default.aspx")) SyndFeed.Copyright = New TextSyndicationContent("(c) 2007, RiderDesign, LLC. All rights reserved.") SyndFeed.Authors.Add(New SyndicationPerson("info@riderdesign.com", "RiderDesign.com", "http://riderdesign.com")) SyndFeed.Language = "en-US" Dim SyndFeedItems As New List(Of SyndicationItem) For Each a In ArticleQuery Dim SyndItem As New SyndicationItem SyndItem.Id = Convert.ToString(a.ArticleID) SyndItem.PublishDate = CType(a.DatePublished, DateTimeOffset) SyndItem.Title = TextSyndicationContent.CreatePlaintextContent(a.Ar ticleTitle) SyndItem.Summary = TextSyndicationContent.CreatePlaintextContent(a.Ar ticleSummary) SyndItem.AddPermalink(New Uri("http://riderdesign.com/articles/displayarticle.aspx?ArticleID=" & a.ArticleID)) SyndFeedItems.Add(SyndItem) Next SyndFeed.Items = SyndFeedItems SyndFeed.SaveAsRss20(XWriter) XWriter.Flush() XWriter.Close() Cache.Insert("RssFeed", XWriter.ToString(), Nothing, DateTime.Now.AddHours(12), TimeSpan.Zero) Return XWriter.ToString End Using End Function |
|
|||
|
Re: Why i am getting System.Security exception with RSS feed code
Fixed it
"Showjumper" <nlsdkfja> wrote in message news:%23Wt41YOKJHA.4324@TK2MSFTNGP05.phx.gbl... >I am using the System. ServiceModel.Syndication and linq to creat an RSS >Feed. Everything works fine locally but remotely i get the following error. >Is adjusting the trust level the only way around this or can add some >attribute to the class or is there another option. Trust level adjusting >not an option since on shared hosting. The code for the rss feed folows the >error message. > Thanks > Ashok > > > 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.Security.Permissions.SecurityPermission, > mscorlib, Version=2.0.0.0, Culture=neutral, > PublicKeyToken=b77a5c561934e089' failed. > > > Public Class LinqToRss > Private HttpCon As HttpContext = HttpCon.Current > Private Cache As New Cache > Public Function WriteRss() As String > Dim articleslinq As New ArticlesLINQDataContext > Dim ArticleQuery = From a In articleslinq.Articles Select a.ArticleID, > a.ArticleSummary, a.ArticleTitle, a.DatePublished, a.ArticleText, > a.IsActive Where IsActive = "Active" Order By DatePublished Descending > HttpCon.Response.Buffer = False > HttpCon.Response.Clear() > HttpCon.Response.ContentType = "application/xml" > Using XWriter = XmlWriter.Create(HttpCon.Response.OutputStream) > Dim SyndFeed As New SyndicationFeed > SyndFeed = New SyndicationFeed("RiderDesign.com Articles", "The latest > ASP.NET articles and news from RiderDesign.com.", New > Uri("http://www.RiderDesign.com/rss/default.aspx")) > SyndFeed.Copyright = New TextSyndicationContent("(c) 2007, RiderDesign, > LLC. All rights reserved.") > SyndFeed.Authors.Add(New SyndicationPerson("info@riderdesign.com", > "RiderDesign.com", "http://riderdesign.com")) > SyndFeed.Language = "en-US" > Dim SyndFeedItems As New List(Of SyndicationItem) > For Each a In ArticleQuery > Dim SyndItem As New SyndicationItem > SyndItem.Id = Convert.ToString(a.ArticleID) > SyndItem.PublishDate = CType(a.DatePublished, DateTimeOffset) > SyndItem.Title = > TextSyndicationContent.CreatePlaintextContent(a.Ar ticleTitle) > SyndItem.Summary = > TextSyndicationContent.CreatePlaintextContent(a.Ar ticleSummary) > SyndItem.AddPermalink(New > Uri("http://riderdesign.com/articles/displayarticle.aspx?ArticleID=" & > a.ArticleID)) > SyndFeedItems.Add(SyndItem) > Next > SyndFeed.Items = SyndFeedItems > SyndFeed.SaveAsRss20(XWriter) > XWriter.Flush() > XWriter.Close() > Cache.Insert("RssFeed", XWriter.ToString(), Nothing, > DateTime.Now.AddHours(12), TimeSpan.Zero) > Return XWriter.ToString > End Using > End Function > |
![]() |
|
| Thread Tools | Search this Thread |
| Display Modes | |
|
|