Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > RSS Feeds

Reply
Thread Tools

RSS Feeds

 
 
sck10
Guest
Posts: n/a
 
      10-03-2006
Hello,

I am trying to learn how to consume RSS feeds and downloaded the example
from the MSDN site:

http://msdn.microsoft.com/coding4fun...spx?print=true


However, I am getting the following error at:
rssData.ReadXml(rssFeed.GetResponse().GetResponseS tream()); even though I
can go directly to the site.

Any help with this would be appreciated.

Thanks, sck10



private DataSet RefreshFeed()
{
HttpWebRequest rssFeed =
(HttpWebRequest)WebRequest.Create("http://msdn.microsoft.com/vbasic/rss.xml");

DataSet rssData = new DataSet();
rssData.ReadXml(rssFeed.GetResponse().GetResponseS tream());

return rssData;
}


Error Statement
+++++++++++++++++++++
System.Net.WebException was unhandled by user code
Message="Unable to connect to the remote server"
Source="System"
StackTrace:
at System.Net.HttpWebRequest.GetResponse()
at RssList.RefreshFeed() in
c:\Inetpub\wwwroot\gsttcsharp\ztest\rss\RssList.as cx.cs:line 30
at RssList.Page_Load(Object sender, EventArgs e) in
c:\Inetpub\wwwroot\gsttcsharp\ztest\rss\RssList.as cx.cs:line 12
at System.Web.Util.CalliHelper.EventArgFunctionCaller (IntPtr fp,
Object o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Cal lback(Object
sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.BasePartialCachingControl.LoadRecurs ive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


 
Reply With Quote
 
 
 
 
Afton Wynona
Guest
Posts: n/a
 
      10-03-2006
you have to create a data source as well


>



 
Reply With Quote
 
 
 
 
=?Utf-8?B?YnJpYW5zW01DU0Rd?=
Guest
Posts: n/a
 
      10-03-2006
Hello sck10,

A simplified way to consume an RSS feed. Place a data repeater rptrRssFeed
on your web form:

XmlReader rssReader = new XmlTextReader(rssUrl);
DataSet ds = new DataSet();
ds.ReadXml(rssReader);

rptrRssFeed.DataSource = ds.Tables["item"];
rptrRssFeed.DataBind();

Add support for caching and exception handling to make it more robust.
--
brians
http://www.limbertech.com


"sck10" wrote:

> Hello,
>
> I am trying to learn how to consume RSS feeds and downloaded the example
> from the MSDN site:
>
> http://msdn.microsoft.com/coding4fun...spx?print=true
>
>
> However, I am getting the following error at:
> rssData.ReadXml(rssFeed.GetResponse().GetResponseS tream()); even though I
> can go directly to the site.
>
> Any help with this would be appreciated.
>
> Thanks, sck10
>
>
>
> private DataSet RefreshFeed()
> {
> HttpWebRequest rssFeed =
> (HttpWebRequest)WebRequest.Create("http://msdn.microsoft.com/vbasic/rss.xml");
>
> DataSet rssData = new DataSet();
> rssData.ReadXml(rssFeed.GetResponse().GetResponseS tream());
>
> return rssData;
> }
>
>
> Error Statement
> +++++++++++++++++++++
> System.Net.WebException was unhandled by user code
> Message="Unable to connect to the remote server"
> Source="System"
> StackTrace:
> at System.Net.HttpWebRequest.GetResponse()
> at RssList.RefreshFeed() in
> c:\Inetpub\wwwroot\gsttcsharp\ztest\rss\RssList.as cx.cs:line 30
> at RssList.Page_Load(Object sender, EventArgs e) in
> c:\Inetpub\wwwroot\gsttcsharp\ztest\rss\RssList.as cx.cs:line 12
> at System.Web.Util.CalliHelper.EventArgFunctionCaller (IntPtr fp,
> Object o, Object t, EventArgs e)
> at System.Web.Util.CalliEventHandlerDelegateProxy.Cal lback(Object
> sender, EventArgs e)
> at System.Web.UI.Control.OnLoad(EventArgs e)
> at System.Web.UI.Control.LoadRecursive()
> at System.Web.UI.Control.LoadRecursive()
> at System.Web.UI.BasePartialCachingControl.LoadRecurs ive()
> at System.Web.UI.Control.LoadRecursive()
> at System.Web.UI.Control.LoadRecursive()
> at System.Web.UI.Page.ProcessRequestMain(Boolean
> includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
>
>
>

 
Reply With Quote
 
sck10
Guest
Posts: n/a
 
      10-03-2006
Thanks brians


"brians[MCSD]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello sck10,
>
> A simplified way to consume an RSS feed. Place a data repeater rptrRssFeed
> on your web form:
>
> XmlReader rssReader = new XmlTextReader(rssUrl);
> DataSet ds = new DataSet();
> ds.ReadXml(rssReader);
>
> rptrRssFeed.DataSource = ds.Tables["item"];
> rptrRssFeed.DataBind();
>
> Add support for caching and exception handling to make it more robust.
> --
> brians
> http://www.limbertech.com
>
>
> "sck10" wrote:
>
>> Hello,
>>
>> I am trying to learn how to consume RSS feeds and downloaded the example
>> from the MSDN site:
>>
>> http://msdn.microsoft.com/coding4fun...spx?print=true
>>
>>
>> However, I am getting the following error at:
>> rssData.ReadXml(rssFeed.GetResponse().GetResponseS tream()); even though I
>> can go directly to the site.
>>
>> Any help with this would be appreciated.
>>
>> Thanks, sck10
>>
>>
>>
>> private DataSet RefreshFeed()
>> {
>> HttpWebRequest rssFeed =
>> (HttpWebRequest)WebRequest.Create("http://msdn.microsoft.com/vbasic/rss.xml");
>>
>> DataSet rssData = new DataSet();
>> rssData.ReadXml(rssFeed.GetResponse().GetResponseS tream());
>>
>> return rssData;
>> }
>>
>>
>> Error Statement
>> +++++++++++++++++++++
>> System.Net.WebException was unhandled by user code
>> Message="Unable to connect to the remote server"
>> Source="System"
>> StackTrace:
>> at System.Net.HttpWebRequest.GetResponse()
>> at RssList.RefreshFeed() in
>> c:\Inetpub\wwwroot\gsttcsharp\ztest\rss\RssList.as cx.cs:line 30
>> at RssList.Page_Load(Object sender, EventArgs e) in
>> c:\Inetpub\wwwroot\gsttcsharp\ztest\rss\RssList.as cx.cs:line 12
>> at System.Web.Util.CalliHelper.EventArgFunctionCaller (IntPtr fp,
>> Object o, Object t, EventArgs e)
>> at System.Web.Util.CalliEventHandlerDelegateProxy.Cal lback(Object
>> sender, EventArgs e)
>> at System.Web.UI.Control.OnLoad(EventArgs e)
>> at System.Web.UI.Control.LoadRecursive()
>> at System.Web.UI.Control.LoadRecursive()
>> at System.Web.UI.BasePartialCachingControl.LoadRecurs ive()
>> at System.Web.UI.Control.LoadRecursive()
>> at System.Web.UI.Control.LoadRecursive()
>> at System.Web.UI.Page.ProcessRequestMain(Boolean
>> includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
>>
>>
>>



 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      10-04-2006
Hello Steve,

Have you got the code working?

From the original error info and callstack you provided, the problem is
likely due to the web access through the HttpWebRequest class( exception
raises at WebRequest.GetResponse ...).

When using httpwebrequest, one thing we'd take care is whether the
webrequest component can get a correct web proxy (if it is required in the
certain network environment). You can try using the system's default proxy
(from IE setting...) or explicitly specify a proxy. e.g.

==================
protected void Page_Load(object sender, EventArgs e)
{
HttpWebRequest request =
WebRequest.Create("http://msdn.microsoft.com/vbasic/rss.xml") as
HttpWebRequest;

request.Method = "GET";
request.Proxy = WebProxy.GetDefaultProxy();
//request.Proxy = new WebProxy("myproxy", 80);

HttpWebResponse response = request.GetResponse() as HttpWebResponse;


Stream stream = response.GetResponseStream();

DataSet ds = new DataSet();
ds.ReadXml(stream);

stream.Close();
response.Close();


GridView1.DataSource = ds.Tables["item"];
GridView1.DataBind();
}
==================

Hope this helps also.


Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
sck10
Guest
Posts: n/a
 
      10-04-2006
Hi Steven,

I tried your code, but I got the error:
System.Net.WebProxy.GetDefaultProxy()' is obsolete.

Also, I have created a page that uses the XmlDataSource control

<asp:XmlDataSource runat="server"
ID="XmlDataSource"
DataFile="~/ztest/rss/msdnvb.xml"
XPath="rss/channel/item" />

and I created a page that calls the XmlTextReader:
try
{
string rssUrl = "http://msdn.microsoft.com/vbasic/rss.xml";
//rssUrl = "http://myxml.com/ztest/rss/msdnvb.xml";
XmlReader rssReader = new XmlTextReader(rssUrl);
DataSet ds = new DataSet();
ds.ReadXml(rssReader);

rptRSS.DataSource = ds.Tables["item"];
rptRSS.DataBind();
}

catch(Exception ex)
{
this.lblMessageText.Text = "RSS Feed Error: " +
ex.Message.ToString();
}

When I run the last two pages, I get the error: "Unable to connect to the
remote server". So I copied the xml file
(http://msdn.microsoft.com/vbasic/rss.xml) and the xsl file from the
Microsoft site to my site. When I did that, I could read the file in both
pages. However, I am unable to pull the file from other sites. Do you
think this relates to the original problem that you addressed?

By the way, which method would you prefer? the XmlDataSource control or
using XmlTextReader?

Thanks again, sck10







"Steven Cheng[MSFT]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello Steve,
>
> Have you got the code working?
>
> From the original error info and callstack you provided, the problem is
> likely due to the web access through the HttpWebRequest class( exception
> raises at WebRequest.GetResponse ...).
>
> When using httpwebrequest, one thing we'd take care is whether the
> webrequest component can get a correct web proxy (if it is required in the
> certain network environment). You can try using the system's default
> proxy
> (from IE setting...) or explicitly specify a proxy. e.g.
>
> ==================
> protected void Page_Load(object sender, EventArgs e)
> {
> HttpWebRequest request =
> WebRequest.Create("http://msdn.microsoft.com/vbasic/rss.xml") as
> HttpWebRequest;
>
> request.Method = "GET";
> request.Proxy = WebProxy.GetDefaultProxy();
> //request.Proxy = new WebProxy("myproxy", 80);
>
> HttpWebResponse response = request.GetResponse() as
> HttpWebResponse;
>
>
> Stream stream = response.GetResponseStream();
>
> DataSet ds = new DataSet();
> ds.ReadXml(stream);
>
> stream.Close();
> response.Close();
>
>
> GridView1.DataSource = ds.Tables["item"];
> GridView1.DataBind();
> }
> ==================
>
> Hope this helps also.
>
>
> Sincerely,
>
> Steven Cheng
>
> Microsoft MSDN Online Support Lead
>
>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>



 
Reply With Quote
 
sck10
Guest
Posts: n/a
 
      10-05-2006
Hi Steven,

The issue has been resolved.


"Steven Cheng[MSFT]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello Steve,
>
> Have you got the code working?
>
> From the original error info and callstack you provided, the problem is
> likely due to the web access through the HttpWebRequest class( exception
> raises at WebRequest.GetResponse ...).
>
> When using httpwebrequest, one thing we'd take care is whether the
> webrequest component can get a correct web proxy (if it is required in the
> certain network environment). You can try using the system's default
> proxy
> (from IE setting...) or explicitly specify a proxy. e.g.
>
> ==================
> protected void Page_Load(object sender, EventArgs e)
> {
> HttpWebRequest request =
> WebRequest.Create("http://msdn.microsoft.com/vbasic/rss.xml") as
> HttpWebRequest;
>
> request.Method = "GET";
> request.Proxy = WebProxy.GetDefaultProxy();
> //request.Proxy = new WebProxy("myproxy", 80);
>
> HttpWebResponse response = request.GetResponse() as
> HttpWebResponse;
>
>
> Stream stream = response.GetResponseStream();
>
> DataSet ds = new DataSet();
> ds.ReadXml(stream);
>
> stream.Close();
> response.Close();
>
>
> GridView1.DataSource = ds.Tables["item"];
> GridView1.DataBind();
> }
> ==================
>
> Hope this helps also.
>
>
> Sincerely,
>
> Steven Cheng
>
> Microsoft MSDN Online Support Lead
>
>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>



 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      10-09-2006
Thanks for your followup Steve,

Glad that you've got the issue resolved.

BTW, it would also be great that if you can share your final solution with
us, that will be helpful to other members also.

Have a good day!


Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
sck10
Guest
Posts: n/a
 
      10-10-2006
Hi Walter,

This is what I am using, but you also suggested that I use a custom tool:

try
{
WebRequest req =
WebRequest.Create(http://rss.cnn.com/rss/cnn_topstories.rss);

// Get Website Proxy
req.Proxy = new WebProxy("global.proxy.lucent.com:8000", true);
req.Proxy.Credentials = CredentialCache.DefaultCredentials;
WebResponse resp = req.GetResponse();

// Stream the data
StreamReader textReader = new StreamReader(resp.GetResponseStream());
XmlTextReader xmlReader = new XmlTextReader(textReader);
//XmlReader rssReader = new XmlTextReader(rssUrl);

// Build Dataset
DataSet dsRSS = new DataSet();
dsRSS.ReadXml(xmlReader);

// Populate Repeater Tool
rptRSS.DataSource = dsRSS.Tables["item"];
rptRSS.DataBind();
}

catch(Exception ex)
{
this.pnlMessage.Visible = true;
this.lblMessageTitle.Text = "RSS Feed Error";
this.lblMessageText.Text =
"<span class=BlkB>Record Not Found</span><br />" +
"Problems consuming RSS Feed for" +
"<br /><br /><span class=BlkB>RSS Feed Error</span><br />" +
ex.Message.ToString();
}

Regards, sck10


"Steven Cheng[MSFT]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thanks for your followup Steve,
>
> Glad that you've got the issue resolved.
>
> BTW, it would also be great that if you can share your final solution with
> us, that will be helpful to other members also.
>
> Have a good day!
>
>
> Sincerely,
>
> Steven Cheng
>
> Microsoft MSDN Online Support Lead
>
>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>



 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      10-11-2006
Hi Steve,

Thanks for the followup and sharing the code with us.

BTW, I think you've mistaken me with Walter as Walter has also worked with
you in anthoer thread

Have a good day!


Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
 
 
Reply

Thread Tools

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Two ways to generate RSS - rss/maker and rss/2.0 - which is better? Jonathan Groll Ruby 1 06-27-2009 03:53 AM
How to display "No Rss feeds new availabe" when there are no FEEDS Patrick Olurotimi Ige ASP .Net 2 05-04-2005 11:50 PM
Firefox and RSS feeds that require authentication ttfg Firefox 0 03-25-2005 11:51 PM
Thunderbird RSS feeds Jeroen Verellen Firefox 0 10-27-2004 11:40 AM
Searches in multiple RSS feeds -> new rss feed Motta XML 1 06-09-2004 10:55 PM



Advertisments