Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello
i developed news site and am trying to read rss from another site
i used this code to read
C#
private void GetRSS()
 {
     try
     {
         WebRequest rssReq = WebRequest.Create("http://www.aljazeera.net/AljazeeraRss/845674de-e247-4149-b2c4-432d70b0076b/acefc2c1-1a68-4977-91c3-969026916497");

         //Create a Proxy
         WebProxy px = new WebProxy("http://www.aljazeera.net/AljazeeraRss/845674de-e247-4149-b2c4-432d70b0076b/acefc2c1-1a68-4977-91c3-969026916497", true);
         //   XPath="/rss/channel/item";
         //Assign the proxy to the WebRequest
         rssReq.Proxy = px;

         //Set the timeout in Seconds for the WebRequest
         rssReq.Timeout = 5000;
         try
         {
             //Get the WebResponse
             WebResponse rep = rssReq.GetResponse();

             //Read the Response in a XMLTextReader
             XmlTextReader xtr = new XmlTextReader(rep.GetResponseStream());

             //Create a new DataSet
             DataSet ds = new DataSet();
             //Read the Response into the DataSet
             ds.ReadXml(xtr);
             //Bind the Results to the Repeater
             Repeater1.DataSource = ds.Tables[3]; ;
             Repeater1.DataBind();
         }
         catch(Exception EX)
         {
             throw EX;
         }
         //ProcessRSSItem("http://www.bbc.co.uk/arabic/index.xml");

     }
     catch (Exception EX)
     {
         throw EX;
     }
 }

its working very nice on local host but when i upload it on my godaddy account it doesn't read any thing and i have this error

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.
can any body describe the problem for me and gave me a solution


regards
Posted
Updated 22-Sep-12 5:41am
v2

This issue would happen when you download a file from Internet or Network Location, etc. Windows now preserves the zone information for file(s). This identifies where the file came from and displays appropriate warning messages, indicating you to be careful.

Resolution: Go to the properties of precompiled dll’s, check to see if it has following security message (at the bottom of the window): "This file came from another computer and might be blocked to help protect this computer." If present, click "Unblock", "Apply" and "OK".

Details, refer here: MSDN Blogs: System.Security.SecurityException: Request for the permission of type [^]
 
Share this answer
 
Security issues can come from too many things to be able to give you an answer based on this, could you maybe provide the inner exception and/or stacktrace(s).

Even tho, I will give you some common issues I've encountered before:

Most security exceptions are related to cross origin problems, you are trying to download from Aljazeera.com, but you are not that same website. This get's blocked by either your application, your hosting provider, or the other party.
There is a configuration option somewhere to enable cross origin from your application outwards, but I don't remember what it was (sorry).
If it is your hosting provider, probably no/small chance they will change it for you.
If it is the other party, in this case Aljazeera, they probably done this for a reason. (In this case I doubt it is this last option tho)

Another cause can be the network security options from windows. On windows server the default option is to not trust remote sites, so you will need to either allow all remote sites (bad idea), or just add Aljazeera to the white list.

If you can provide more information, we can take a close look at the problem.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900