This article mainly provides code to create your own RSS for others to subscribe...
--- RSS.aspx
<%@ Page language="c#" Codebehind="RSS.aspx.cs" AutoEventWireup="false" Inherits="Socent. RSS" %>
--- RSS.aspx.cs
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace Socent
{
/// <summary>
/// Get aggregated articles
/// </summary>
public class RSS : System.Web.UI.Page
{
Components.GenRSS gr = new Components.GenRSS(); // Instantiate object
string strRSS = "";
private void Page_Load(object sender, System.EventArgs e)
{
Response.ContentType = "application/xml"; // Output and display as xml data
Response.Write (GetRSS());
}
/// <summary>
/// Get aggregated articles
/// </summary>
public string GetRSS()
{
DataSet ds = gr.GenerateRSS(); // Call the GenerateRSS() method to obtain data
strRSS = strRSS + "<rss version="2.0">";
strRSS = strRSS + "<channel>";
strRSS = strRSS + "<title>Made by natives</title>";
strRSS = strRSS + "<link>http://www.socent.com</link>";
strRSS = strRSS + "<description>Made by natives</description>";
for(int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
strRSS = strRSS + "<item>";
strRSS = strRSS + "<title><![CDATA["+ds.Tables[0].Rows[i]["Title"]+"]]></title>";
strRSS = strRSS + "<link>http://www.socent.com/ArticleShow@"+ds.Tables[0].Rows[i]["ID"]+".html</link> ";
strRSS = strRSS + "<description><![CDATA["+ds.Tables[0].Rows[i]["Description"]+"]]></description>";
strRSS = strRSS + "<copyright>Made by natives</copyright>";
strRSS = strRSS + "<pubDate>"+Convert.ToDateTime(ds.Tables[0].Rows[i]["AddDate"].ToString()).ToString("yyyy-MM-dd HH:mm")+ "</pubDate>";
strRSS = strRSS + "<comments>http://www.socent.com/CommentShow@"+ds.Tables[0].Rows[i]["ID"]+".html</comments>";
strRSS = strRSS + "</item>";
}
strRSS = strRSS + "</channel>";
strRSS = strRSS + "</rss>";
return strRSS;
}
#region Code generated by Web Forms Designer
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Forms designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Designer supports required methods - do not use code editor to modify
/// The content of this method.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}