asp.net rss toolkit
2006-12-27 14:58
190 查看
ASP.NET RSS Toolkit
The RSS toolkit includes support for consuming as well as publishing RSS feeds in ASP.NET applications. Features include:RSS Data Source control to consume feeds in ASP.NET applicationsWorks with ASP.NET data bound controls
Implements schema to generate columns at design time
Supports auto-generation of columns at runtime (via ICustomTypeDescriptor implementation)
Caching of downloaded feeds both in-memory and on-disk (persisted across process restarts)
Generation of strongly typed classes for RSS feeds (including strongly typed channel, items, image, handler) based on a RSS URL (the toolkit recognizes RSS and RDF feeds) or a file containing RSS definition. Allows programmatically download (and create) RSS channels using strongly-typed classes. The toolkit includes:Stand-alone command line RSS compiler
Build provider for .rssdl file (containing the list of feed URLs)
Build provider for .rss file (containing RSS XML)
Support for generation of RSS feeds in ASP.NET application including:RSS HTTP handler (strongly typed HTTP handlers are generated automatically by the build providers) to generate the feed.
RSS Hyper Link control (that can point to RSS HTTP handler) to create RSS links
Optional secure encoding of user name into query string to allow generation of personalized feeds
Set of classes for programmatic consumption and generation of RSS feed in a late-bound way, without using strongly types generated classes
The toolkit is packaged as an assembly (DLL) that can be either placed in GAC or in ‘bin’ directory of a web application. It is also usable from client (including WinForms) applications.
RSS Toolkit works in Medium Trust (RssToolkit.dll Assembly either in GAC or in ‘bin’) with the following caveats:
If the ASP.NET application consumes RSS feeds, the trust level must be configured to allow outbound HTTP requests.
To take advantage of disk caching, there must be a directory (configurable via AppSettings["rssTempDir"]) where the trust level policy would allow write access. However, disk caching is optional.
Complete sources are included in the package.
This is v1.0 so of course there could be bugs…
Package Contents
bin/binaries including RssToolkit.dll Assembly and Rssdl.exe command line compiler.
sources/
build.bat to build the binaries. Note: if binaries are re-built then web.config file (and reference directive in pages) in the sample applications need to be updated to change the PublicKeyToken in the assembly reference.
sources/toolkit/
sources for RssToolkit.dll
sources/rssdl/
sources for Rssdl.exe, the command line RSS compiler
samples/
sample ASP.NET application both consuming and publishing RSS feeds
Scenario walkthroughs
The sample places RssToolkit.dll in GAC (one way to install it into GAC is to run “gacutil –i RssToolkit.dll”. The toolkit assembly can also be placed into ‘bin’ directory.To add RSS controls to the VS toolbox, select ‘Choose Items…’ and ‘Browse…’ to RssToolkit.dll.
‘Samples’ directory contains the pages described in the scenarios below.
Scenario 1 -- Consuming RSS feed using RssDataSource control
Add DataList control to the page, select ‘New Data Source’ and choose ‘RssDataSource’.Type in the URL of the RSS feed in the RSS Data Source configuration dialog
Edit DataList template:Remove all existing fields
Add HyperLink
Data bind ‘Text’ to ‘title’ and ‘NavigateURL’ to ‘link’
Generating strongly typed classes to consume feeds
This can be accomplished in two ways:Using Rssdl.exe command line utility and placing the resuling source file into app_code, for example:
rssdl http://rss.msnbc.msn.com/id/3032091/device/rss/rss.xml Msnbc.cs
By placing .rssdl containing the link to the feed(s) into app_code directly:
<rssdl>
<rss name="Msnbc" url="http://rss.msnbc.msn.com/id/3032091/device/rss/rss.xml/" />
</rssdl>
The samples contain a pre-generated sources file for the feed.
Scenario 2 -- Consuming RSS feed using ObjectDataSource control
Add DataList control to the page, select ‘New Data Source’ and choose ‘ObjectDataSource’.Pick the strongly typed Channel as the business object and ‘LoadChannelItems’ as Select Method
Edit DataList template:
Remove all existing fields
Add HyperLink
Data bind ‘Text’ to ‘title’ and ‘NavigateURL’ to ‘link’
Scenario 3 -- Consuming RSS feed programmatically using strongly typed classes
Add a GridView to the page without selecting a data sourceLoad channel using strongly typed class and data bind programmatically:
MyChannel c = MyChannel.LoadChannel();
GridView1.DataSource = c.Items;
GridView1.DataBind();
Scenario 4 -- Consuming RSS feed programmatically using late bound classes
Add a GridView to the page without selecting a data sourceLoad channel using late bound channel class and data bind programmatically:
GenericRssChannel c;
c = GenericRssChannel.LoadChannel("http://myserver/myrss");
GridView1.DataSource = c.SelectItems();
GridView1.DataBind();
Scenario 5 – Publishing RSS feed using strongly typed classes
Place channel schema file (.rss) into app_code directoryCreate HTTP handler (.ashx) derived from the auto-generated strongly typed HTTP handler – override PopulateItems method:
public class MyHandler : MyChannelHttpHandlerBase {
protected override void PopulateChannel(string channelName,
string userName) {
Channel.Items.Add(new MyChannelItem(...));
...
}
}
On the page publishing RSS feed place RssHyperLink control and configure it:Point NavigateUrl to the .ashx handler
Specify ChannelName property to be passed to the handler – useful when a single handler produces multiple channels
Set IncludeUserName to true, to create a secure personalized link with the encoded user name.
Note that RSS properties that are URLs can be entered as app-relative links (~/…) – they will be automatically converted to fully qualified URLs when RSS XML is generated.
Scenario 6 – Publishing RSS feed using late bound classes
Create HTTP handler (.ashx) derived from GenericRssHttpHandlerBase – override PopulateItems method:public class MyHandler : GenericRssHttpHandlerBase {
protected override void PopulateChannel(string channelName,
string userName) {
Channel["title"] = "...";
Channel["link"] = "~/...";
Channel["description"] = "...";
GenericRssElement item = new GenericRssElement();
item["title"] = "Scenario1";
item["description"] = "Consuming RSS feed using RssDataSource";
item["link"] = "~/scenario1.aspx";
Channel.Items.Add(item);
...
}
}
On the page publishing RSS feed place RssHyperLink control and configure it to make NavigateUrl to point to the .ashx handler
---
相关文章推荐
- RSS ToolKit for ASP.NET 2.0
- RSS ToolKit for ASP.NET 2.0
- 基于ASP.NET的Rss开发包:ASP.NET RSS Toolkit
- RSS制作阅读器(利用RssToolkit for asp.net 2.0)
- ASP.NET实现RSS订阅(Rss Toolkit 1.0)
- 基于ASP.NET的Rss开发包:ASP.NET RSS Toolkit
- 利用asp.net输出RSS
- ASP.NET AJAX Control Toolkit 控件说明(转)
- 关于 AjaxControlToolkit requires ASP.NET Ajax 4.0 scripts. 错误
- ASP.NETRSSToolkit(RSS工具)
- ASP.NET AJAX Control Toolkit Release 10301
- ASP.NET Ajax Toolkit使用ModalPopupExtender控件
- ASP.NET读取RSS的方法
- ASP.NET AJAX Control Toolkit Release 10301
- 《ASP.NET AJAX程序设计 第I卷 服务器端ASP.NET AJAX Extensions与ASP.NET AJAX Control Toolkit》试读及免费赠书活动
- 《ASP.NET AJAX程序设计 第I卷 服务器端ASP.NET AJAX Extensions与ASP.NET AJAX Control Toolkit》连载&最新更新
- AjaxControlToolkit的安装使用方法(转)2010年05月03日 星期一 10:54Ajax 最好最新的资源网:http://ajax.asp.net/downloads/default.aspx上面有所有Ajax最新的
- ASP.NET生成RSSFeed
- ASP.NET的SEO(五):Linq to XML---网站地图和RSS Feed
- 《ASP.NET AJAX程序设计 第I卷 服务器端ASP.NET AJAX Extensions与ASP.NET AJAX Control Toolkit》试读及免费赠书活动