Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# XmlReader rss
hello
i developed news site and am trying to read rss from another site
i used this code to read
   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 22-Sep-12 5:20am
Edited 22-Sep-12 5:41am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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 [^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 375
1 Richard Deeming 240
2 _Amy 205
3 CHill60 195
4 Nirav Prabtani 178
0 OriginalGriff 8,104
1 Sergey Alexandrovich Kryukov 7,045
2 Maciej Los 4,039
3 Peter Leow 3,738
4 CHill60 2,912


Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 22 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100