简体   繁体   中英

Cannot access rss feed from MVC application on IIS though proxy

I am trying to read an rss feed from my MVC application. The code works fine when I run it at home, however when I run my local machine at work, or on IIS 7, it fails. I suspect that this is a proxy setting problem, however I have tried modifying the config file to use the default proxy, and in any case understood that IIS went with the IE settings - and I can connect to the internet from the webserver.

The code to access the rss feed is as follows:

    public static List<string> ReadDangerZoneFeed()
    {
        XmlReader reader = XmlReader.Create("http://rssfeedaddress.rss");
        SyndicationFeed feed = SyndicationFeed.Load(reader);

        reader.Close();

        List<string> _DangerZones = new List<string>();

        foreach (var Item in feed.Items)
        {
            _DangerZones.Add(Item.Title.Text);
        }

        return _DangerZones;
    }

The error message occurs ar the XMLReader.Create line and is "Unable to connect to the remote server". I'd very much appreciate any advice,

Many thanks,

Jamie

It turns out all I needed to do was get the specific sites whitelisted on our company proxy. I then added the proxy details to the web.config file as per this answer Is it possible to specify proxy credentials in your web.config? and it all works fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM