This post originated from an RSS feed registered with .NET Buzz
by Scott Watermasysk.
Original Post: Permanent Redirects via Code
Feed Title: ScottW's ASP.NET WebLog
Feed URL: /error.aspx?aspxerrorpath=/blog/rss.aspx
Feed Description: ASP.NET and Blogging
At the the MVP Summit Scott Mitchell asked me what is the preferred way to redirect readers from one RSS feed to another.
My initial response was IIS can do this for you. You just tell IIS which file/directory/site you want to redirect and the new Uri. Many aggregators (RSSBandit, SharpReader, Newsgator, and FeedDemon) are smart enough to detect the permanent redirect (status code 301) and update their subscriptions accordingly.
However, if you do not have IIS access, you are not left out. Using my favorite new tool, “Fiddler”, I was able to quickly see a permanent redirect required just two steps:
Setting the status code to 301
Adding a location header for the redirect.
So now, it is just a matter of writing a couple lines of code:
From here all you would need to do is drop this code in the “old” page, a custom httpModule, or even the global.asax. Obviously you could also add some logic to redirect pages to different locations, find pages with specific patterns, etc.
Speaking of redirects, a quick note to Aggregator authors. While it is very handy to have these updates occur without any user interaction, I would love to not have the redirect “save” until the new Url is validated (ie, you are sure it contains an RSS or Atom feed.). I know quite a few people who lost all of their subscriptions in the hotel's at the MVP summit because the once a day hotel internet registration got updated as the Url for every feed :)