国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
Scott on Writing

FeedBurner and Changing a Blog‘s Feed URL

This weekend I moved over my RSS feed - previously http://ScottOnWriting.NET/sowBlog/Rss.aspx - to a feed managed by FeedBurner (http://feeds.feedburner.com/ScottOnWriting).  FeedBurner serves as a sort of feed URL proxy.  Basically you give FeedBurner a link to your RSS feed and it creates a feed based on that feed.  You then point your subscribers to the FeedBurner feed and FeedBurner serves up your site‘s content, maintains statistics on who‘s subscribing to your blog, and so on.

I decided to move to FeedBurner to realize three benefits (keep in mind that ScottOnWriting.NET (still) runs off of an old version of Scott Watermasysk‘s .Text blogging engine, as I‘ve yet to upgrade to Community Server; previous to today, I was actually using a pre-0.94 version, but today "upgraded" to the official 0.94 release downloadable from the .Text GotDotNet Workspace):

  1. Subscription statistics - FeedBurner provides a number of free statistics, including number of subscribers, number of requests, and aggregator breakdown.
  2. Someone else handles the bandwidth - currently requests to the RSS feed on ScottOnWriting.NET consume roughly 1.5 GB of traffic per week, or 6 GB of traffic per month (in total, ScottOnWriting does about 11 GB of traffic per month).  That‘s a lot of 1s and 0s that would be nice to offload to another party.  (I don‘t believe the pre-0.94 version of .Text I was using supported conditional HTTP GETs (although if I‘m not mistaken the "official" 0.94 release does; had I been using a version that supported conditional GETs this bandwidth requirement would be an order of magnitude lower, I‘d wager, perhaps just a GB for the month.)  (To clarify, while FeedBurner does make requests to the blog‘s RSS URL, it caches the results for a period of time, thereby reducing the bandwidth demands for my server.)
  3. FeedBurner has a couple of neat “publicizing“ tools - FeedBurner includes a number of tools to easily make links to add your blog to My Yahoo!, MyMSN, newgator Online, and so on.  Additionally, there are nifty little tools you can use to “show off“ how many folks subscribe to your blog, a la:

When changing over your RSS feed URL the main challenge is making sure that your existing subscriber base starts to use the new feed URL.  There are, to my knowledge, to ways this can be done, with the first of the two ways being the ideal way:

  1. Have your old feed URL emit an HTTP 301 status code - The HTTP 301 status code is a message from the server to the client saying, “Hey, this resource has been permanently moved to URL xyz.“  The client, then, can make a new request to the specified URL; too, if there‘s some database being used to track the URL, this message informs the client that it‘s time to update the database and use the new location.  If I‘m not mistaken, virtually all modern aggregators support HTTP 301 status codes and will automatically update a site‘s feed URL to use the newly specified location.
  2. Tell people of your new feed URL - if you do not have control over your blog website you may not be able to take the steps needed to replace the current feed URL with an HTTP 301 status code.  In this case, the only approach I know of to inform users of the new feed URL is simply through word of mouth.  That is, you‘ll just have to post on your blog an entry telling users to update their aggregators.  As Kent Sharkey has noted, though, the results may be somewhat disappointing.

Since I run ScottOnWriting.NET myself (well, through a web hosting company), I have control over these matters.  The only challenge, then, was getting .Text to play nice.  In .Text version 0.94 the site‘s RSS feed comes from a file named Rss.aspx.  This file, though, does not actually exist; rather, in the Web.config file all requests are handed off to a .Text HTTP Handler.  When a request comes in for Rss.aspx, .Text generates the appropriate output.

To get Rss.aspx replaced with an HTTP 301 status code, the first step is to create an Rss.aspx file in your blog‘s root directory.  The code needed for this page is alarmingly simple - all you want to do is return an HTTP 301 specifying the new feed URL, like so:

<script runat="server" language="C#">
void Page_Load(object sender, EventArgs e)
{
    Response.Status = "301 Moved Permanently";
    Response.AddHeader("Location", "
http://feeds.feedburner.com/ScottOnWriting");
}
</script>

(Of course replace the http://feeds.feedburner.com/ScottOnWriting Location header value with the URL of your new RSS feed...)

Creating this file is not enough.  In fact, even after creating this file if you visit Rss.aspx through your browser you‘ll still see the complete RSS feed rather than being auto-redirected to the specified URL.  This is because the ASP.NET engine is handing off the request to the .Text HTTP Handler rather than handling the request itself.  If you look at the <httpHandlers> section in the Web.config file you‘ll find an entry like:

<add verb="*" path="*.aspx" type="Dottext.Framework.UrlManager.UrlReWriteHandlerFactory,Dottext.Framework" />

This entry says, “Any request for an ASP.NET page should be handled by the class Dottext.Framework.UrlManager.UrlReWriteHandlerFactory,Dottext.Framework,” and HTTP Handler. This includes requests for Rss.aspx.  Hence we need to add the following line to the <httpHandlers> section:

<add verb="*" path="Rss.aspx" type="System.Web.UI.PageHandlerFactory" />

That tells the ASP.NET engine to take care of requests to Rss.aspx.  At first I naively thought that I was done, but I had just unwittingly setup an infinite loop!  When a request comes into Rss.aspx, it sends back a 301 status code to the client, saying, “No, no, no, you want to go to this FeedBurner URL.“  This is what we want to tell people coming through a browser or aggregator, but remember that FeedBurner also needs to know the URL of the site‘s feed, which, at this point, I had set simply as Rss.aspx!  So when FeedBurner periodically checked to see if a new version of my feed was available it requested Rss.aspx, which told it to check itself, which says to check Rss.aspx, which says to check itself, which... you get the point.

Instead, what I needed to do was rename .Text‘s Rss.aspx to something else, like RssFromText.aspx and instruct FeedBurner to use this alternate, “secretive” feed URL.  With this setup, a user who already subscribes to ScottOnWriting.NET through Rss.aspx will automatically be switched over to FeedBurner.  FeedBurner‘s RSS content will be populated from RssFromText.aspx, which will be generated from .Text, reflecting the most recent blog entries.  No more infinite loops!

To accomplish this I had to edit blog.config to tell .Text that it should use RssFromText.aspx as its RSS feed URL as opposed to Rss.aspx.  This involved updating the appropriate <HttpHandler> line like so:

<HttpHandler Pattern = "(?:\/RssFromText.aspx)$" Type = "Dottext.Framework.Syndication.RssHandler, Dottext.Framework" HandlerType = "Direct" />

With this addition, requests now to Rss.aspx are sent back an HTTP 301 status code, but FeedBurner can still slurp down the site‘s content through RssFromText.aspx.

Next, you‘ll probably want to update the link to the site‘s feed in the My Links section (since this will point the users to Rss.aspx, but you want them to go directly to the FeedBurner link).  (In actuality, this step is probably optional since even if you do leave it as Rss.aspx, when the attempt to view that page through a browser or slurp it through an aggregator, they‘ll get the 301 status code and auto-redirect to the FeedBurner URL... but still, for completeness let‘s change this link.)  To accomplish this, simply edit the MyLinks.ascx file in the ~/Skins/skin_name/Controls/ directory.  With version 0.94 you‘ll find two HyperLink controls that .Text automatically looks for and sets their NavigateUrl properties to Rss.aspx - these controls have IDs Syndication and XMLLink.  Even if you explicitly set the NavigateUrl properties to your FeedBurner URL, .Text will overwrite it and the link will be rendered as Rss.aspx.  If you try to simply remove these HyperLink controls you‘ll find that (at least with 0.94) .Text will barf.  What I did was simply set their Visible property to False.  I then added two HyperLink Web controls of my own that referenced the new feed URL.

There‘s one more facet that should be changed, although I‘ve not made the change since (to my understanding) you‘d need to actually hack the .Text source code, recompile, and re-deploy.  In the portion of the web pages in your blog you‘ll find a tag that‘s used for RSS feed auto-discovery:

<link rel="alternate" href="http://scottonwriting.net/sowblog/rss.aspx" type="application/rss+xml" title="RSS" >

Ideally the href attribute would contain the URL of your new feed... but I didn‘t feel like going through the headache of pecking through the source, making a change, testing, and so forth.  So I just left it as-is, figuring in the worst case someone will “discover” my feed to be Rss.aspx, which will automatically be updated to the FeedBurner syndication URL as soon as their aggregator makes its first request to Rss.aspx.

The FeedBurner service looks pretty cool upon first glance.  Once this new feed URL gets some use and I get some metrics in FeedBurner‘s database, I plan on sharing some of the stats... it‘ll be interesting to see what the most popular aggregator out there is for those who are ASP.NET developers (the primary audience of this blog, I imagine), among other data points.

posted on Sunday, August 28, 2005 5:23 PM

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
ASP.NET(C#)怎樣取得當(dāng)前頁面的文件名
ASP.net獲取當(dāng)前頁面的文件名,參數(shù),域名等方法
電子書網(wǎng)址大收集
使用Global.asax實(shí)現(xiàn)ASP.Net的URL重寫
博客園 - The shortest answer is doing - Asp.net地址轉(zhuǎn)義(分析)加強(qiáng)版--Dottext的地址分析模塊的不足之處及相應(yīng)的解決方案
ASP.NET 獲取來源網(wǎng)站的網(wǎng)址,獲取上一網(wǎng)頁的網(wǎng)址,獲取來源網(wǎng)頁的URL,獲取上一網(wǎng)頁的URL
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服