本文主要提供代码,创建自己的rss,供别人订阅...
--- 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>
 ///  取得聚合文章
 /// </summary>
 public class rss : system.web.ui.page
 {
  components.genrss gr = new components.genrss(); // 实例化对象
  string strrss = "";
  private void page_load(object sender, system.eventargs e)
  {
   response.contenttype = "application/xml"; // 输出并按xml数据显示
   response.write (getrss());
  }
  /// <summary>
  /// 取得聚合文章
  /// </summary>
  public string getrss()
  {   
   dataset ds = gr.generaterss(); // 调用generaterss()方法,获得数据
   strrss = strrss + "<rss version=\"2.0\">";
   strrss = strrss + "<channel>";
   strrss = strrss + "<title>土人制造</title>";
   strrss = strrss + "<link>http://www.socent.com</link>";
   strrss = strrss + "<description>土人制造</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>土人制造</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 web 窗体设计器生成的代码
  override protected void oninit(eventargs e)
  {
   //
   // codegen: 该调用是 asp.net web 窗体设计器所必需的。
   //
   initializecomponent();
   base.oninit(e);
  }
  /// <summary>
  /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  /// 此方法的内容。
  /// </summary>
  private void initializecomponent()
  {    
   this.load += new system.eventhandler(this.page_load);
  }
  #endregion
 }
}
以上就是创建自己的rss实例教程的详细内容。
   
 
   