Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > WebRequest View modes: 
User avatar
Member
Member
TonyG - 3/3/2011 2:07:21 PM
   
WebRequest
I am using Kentico V5.5 R2.

I have one Kentico Site and another .net 4.0 Site.

I have a news Rss feed setup on the Kentico Site which I am trying to read from the other site using Web Request.

The code:

WebRequest RSSRequest = WebRequest.Create("http://{SITE}/news.aspx?rss=news");


This returns 404 exception with web request. However if I go to that url in the browser it renders correctly.

Is there a better way to do this or how can I make it work?

User avatar
Kentico Consulting
Kentico Consulting
kentico_mirekr - 3/7/2011 2:47:34 AM
   
RE:WebRequest
Hi,

Could you please let me know what you are trying to achieve with this approach? Is the other web site from where are you trying to read the RSS feed Kentico CMS web site?

RSS feed is basically XML document, so you can use following approach to read the XML file:

            // Get XML resolver to ensure credentials
XmlResolver xmlResolver = new XmlUrlResolver();
xmlResolver.Credentials = CredentialCache.DefaultCredentials;

// Get XML text reader for given URL
XmlTextReader xmlTextReader = new XmlTextReader(UrlHelper.GetAbsoluteUrl("http://localhost:52318/CMS/cmspages/newsrss.aspx"));
xmlTextReader.XmlResolver = xmlResolver;

// Get data from XML
DataSet dataset = new DataSet();

// Read the XML
dataset.ReadXml(xmlTextReader);


You can find useful information about reading XML documents on the internet.

Best regards,
Miro Remias.