FeedBurner and HttpWebRequest Failure

by aboo bolaky 26. September 2008 08:34

 

The other day, I subscribed this blog to FeedBurner . This was all meant to be the way forward Tongue out. What i was trying to do was to use a Web Request to someone's feed url (in my example, http://feeds.feedburner.com/aboobolaky) to gather a few blog entries from the feed (a bit like the blog roll on the left hand side!).

It turns out that the web request fails with a status of "ProtocolError" , with an Exception of "The remote server returned an error: (404) Not Found." . However, if you use an RSS Reader or even point your web browser to the link, it works just fine!! Foot in mouth

Question here..How do we isolate the problem?

  • Is this intentional?
  • Is a proxy server responsible for this?
  • Or, maybe it has something to do with the User Agent?

 

I'll be thinking about this and post an update sooner or later.

In the meantime, I'd better revert my feed url to how it was before

using System;
using System.Configuration;
using System.Data;
using System.Web;
using System.Text;
using System.Net;
using System.IO;
using System.Xml;

public partial class _Default : System.Web.UI.Page
{ 
public class RequestState 
{ 

// This class stores the State of the request. 
const int BUFFER_SIZE = 1024; 
public StringBuilder requestData; 
public byte[] BufferRead; 
public HttpWebRequest Request; 
public HttpWebResponse response; 
public Stream streamResponse; 

	public RequestState() 
	{ 
		BufferRead = new byte[BUFFER_SIZE]; 
		requestData = new StringBuilder(); 
		Request = null; 
		streamResponse = null; 
	} 
} 
protected void Page_Load(object sender, EventArgs e) 
{ 
	HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create("http://feeds.feedburner.com/aboobolaky"); 
	RequestState myRequestState = new RequestState(); 
	myRequestState.Request = httpRequest; 
	httpRequest.BeginGetResponse(ProcessResponse, myRequestState); 
} 
private static void ProcessResponse(IAsyncResult async) 
{ 
	RequestState state = (RequestState)async.AsyncState;
	try 
		{ 
			using (HttpWebResponse response = (HttpWebResponse)state.Request.EndGetResponse(async)) 
				{ 
					XmlDocument doc = new XmlDocument(); 
					doc.Load(response.GetResponseStream()); 
					XmlNodeList nodes = doc.SelectNodes("rss/channel/item"); 
					foreach (XmlNode node in nodes) 
					{ 
						string title = node.SelectSingleNode("title").InnerText; 
						/*likewise,list the relevant nodes under /rss/channel/item..*/ 
					} 
				} 
		} 
	catch (System.Net.WebException ex) 
		{
			throw ex; 
		}
} 

} 

Tags: ,

.Net | Asp.Net

Tag cloud

Flash Player 9 required.

About Me

I wish I could write something here..
//TODO: ElaborateMe