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.

Go Back   { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Programming > ASP.NET

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-08-2008, 02:35 AM
Showjumper
 
Posts: n/a
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


Reply With Quote
  #2 (permalink)  
Old 10-08-2008, 03:05 AM
Showjumper
 
Posts: n/a
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
>



Reply With Quote
Reply

  { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Programming > ASP.NET


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 03:48 PM.


Powered by vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
© 1999-2008 mindfrost82.com v11.0


Sponsors:
Credit Cards UK | Credit Card | Loans | Loans | Business Gifts



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114