Creating an RSS Feed with ASP.Net Written in C# - Creating the Pages
(Page 2 of 4 )
There will be two files in this project. One will contain an ASP.Net repeater control that will put the data into the XML file. The other will be a code behind page that contains all the logic for getting the data. You can create these pages in an IDE like Visual Studio or Visual Web Developer, or just use a plain text editor. If you are using a text editor, you will have to copy the pages onto your IIS server in order to test them.
First of all, create a page called rss.aspx. This is the page that contains the data repeater control, at which your users will actually point their RSS reader applications.
At the very top of the page, you need to have the line shown below. It is the page declaration statement, and tells the page how to behave:
<%@ Page language="c#" CodeFile="rss.aspx.cs" ContentType="text/xml" AutoEventWireup="false" Inherits="SyndicationDemo"%>
The first declaration is the language; it tells you what code to expect on this page. It is set to C#.
The next part of this is the CodeFile section. It is telling us the code for the page is located within another file, in this case the rss.aspx.cs file.
The next section is important; it is setting the ContentType of the page. If this were a normal web page you wouldn't have to change it (it defaults to HTML), but we want to send XML to the browser (or RSS reader), so we make it text/xml.
The Inherits section tells the page what class to inherit from the code behind page. In the case it's the SyndicationDemo class, which we will be writing next.
We will now create the code behind page. It makes more sense to do this before we add the repeater to this page, so you can see what the repeater is actually outputting.
Next: Code Behind Page >>
More C# Articles
More By Luke Niland