Article ID: 2060083 - View products that this article applies to.
This article describes an All-In-One Code Framework sample that is available for download. This code sample demonstrates how to create a RSS Feed in ASP.NET.
Before you go through this sample, we assume that you are familiar with RSS, including its usage, format, and so on. If not, refer to the RSS Tutorial Web site in the "References" section of this article. It describes what RSS is and the basic format of a standard RSS file.
Note The code sample that is described in this article is not intended to be used in a production environment. It is provided only for illustration. This code sample is released under the terms of the Microsoft Public License (MS-PL).
Collapse this imageExpand this image
Download informationTo download this code sample, click the following link:
Technical overviewThe sample provides two pages: AddArticle.aspx and Rss.aspx.
The AddArticle.aspx page supports a feature of updating the database via a simple FormView control. You can insert, edit and delete a record by using this FormView control when you are operating some articles. The Rss.aspx page can give the users who subscribe the RSS Feed the latest status of these records in the data table.
To achieve the Rss.aspx page, you first need to import the XML namespace and change the page's ContentTpye to XML as the RSS file is an XML file other than a normal web page.
The RSS Feed content contains three parts: the opening, the body and the ending. You can also separate the code into three methods: WriteRssOpening(), WriteRssBody() and WriteRssEnding().
In the WriteRssOpening() method, you need to set the version, the title, the simple description and some other information of this RSS Feed according to the RSS’s definition.
When you write the body part, you can use the “For… Each…” statement to loop through the rows in the source Table and output them one by one.
After all the records have been written to the XML, you need to close the opened element in the WriteRssEnding() method.
Also, you need to end the Response of the current request from the client. Otherwise, an error will occur and all the operations you performed will be discarded. When this problem occurs, you will recieve an error message "Internet Explorer cannot display this feed" on the page.
NoteFor more information about how to create the sample application and how to deploy the sample application, see the Readme.txt file that is included in the download package.
LanguagesThis code sample contains the following programming languages:
Collapse this tableExpand this table
What is All-In-One Code Framework?All-In-One Code Framework shows most Microsoft development techniques by using code samples in different programming languages. Each example is carefully selected, composed, and documented to show one common code scenario. For more information about All-In-One Code Framework, visit the following Web site:
How to find more All-In-One Code Framework samplesTo find more All-In-One Code Framework samples, you can simply click the following link:
For more information, visit the following Web sites:
(http://go.microsoft.com/fwlink/?LinkId=151500)for other considerations.
Article ID: 2060083 - Last Review: September 28, 2010 - Revision: 2.0