惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
Cybersecurity and Infrastructure Security Agency CISA
D
Darknet – Hacking Tools, Hacker News & Cyber Security
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
S
Schneier on Security
L
Lohrmann on Cybersecurity
S
Securelist
P
Palo Alto Networks Blog
SecWiki News
SecWiki News
T
Troy Hunt's Blog
H
Hacker News: Front Page
AWS News Blog
AWS News Blog
Latest news
Latest news
Hacker News - Newest:
Hacker News - Newest: "LLM"
NISL@THU
NISL@THU
The Hacker News
The Hacker News
F
Full Disclosure
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
大猫的无限游戏
大猫的无限游戏
O
OpenAI News
P
Proofpoint News Feed
Know Your Adversary
Know Your Adversary
G
GRAHAM CLULEY
博客园_首页
Attack and Defense Labs
Attack and Defense Labs
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Security Latest
Security Latest
云风的 BLOG
云风的 BLOG
K
Kaspersky official blog
WordPress大学
WordPress大学
www.infosecurity-magazine.com
www.infosecurity-magazine.com
宝玉的分享
宝玉的分享
L
LINUX DO - 热门话题
博客园 - 叶小钗
L
LINUX DO - 最新话题
Martin Fowler
Martin Fowler
N
News | PayPal Newsroom
Project Zero
Project Zero
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
PCI Perspectives
PCI Perspectives
月光博客
月光博客
IT之家
IT之家
Recent Announcements
Recent Announcements
T
The Exploit Database - CXSecurity.com
D
DataBreaches.Net
J
Java Code Geeks
酷 壳 – CoolShell
酷 壳 – CoolShell
Last Week in AI
Last Week in AI
Google Online Security Blog
Google Online Security Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知

博客园 - peak

windows 服务器时间同步失败处理方法 利用批处理自动创建schtasks系统任务 抓取网站编码信息及内容 在线调试利器Fiddler AutoResponse jquery跨域调用WCF Base-64 字符串中的无效字符 Ie7下鼠标滚轮失效 Android 笔记二(取得根目录权限) Android 笔记一 捕获asp.net ValidationSummary 控件消息。 - peak Sql Split 函数 兼容IE,Firefox 图片即时显示 asp.net 中插入flash - peak - 博客园 迷茫 windows service 之访问权限 windows Service 之调试过程 比尔盖兹在某个大学毕业典礼上的演讲中,对毕业生提出十一项极为睿智的人生建议 MSDN上关于泛型的例子 泛型
Rss的浏览器之痛
peak · 2009-08-01 · via 博客园 - peak

      好久没写东西了,就写写最近遇到的问题吧!几天前写了一个关于Rss feed的code。其实说来这种东西在网上一搜一堆一堆,没有什么难度可言。
可就是这不可能出现的问题,产生了问题。
      在写好代码后,在Ie7 和Ie8 下显示正常(ie7后集成了rss功能)。本以为这样就大功告成,当准备收工的时候,测试组说Rss在firefox下显示有问题。
赶快抓紧时间调整,然后放到firefox下问题依然存在。在网上找些大的网站,比对Rss的格式也没发现什么问题。花了一段时间后,无意间发现在写Rss头时,
link 是相对路径如“/home.aspx”,这样在ie7和ie8下是可以被识别的,可是在firefox下是无法识别的。所以,在写Rss头时,link 一定要写绝对路径如:
http://localhost:8034/rsss.aspx”。以下附上一段写rss的简单代码。

private const String HTTP = "http://";
 
protected void LoadData()
{
   var context 
= HttpContext.Current;
   var writer 
= new XmlTextWriter(context.Response.OutputStream, System.Text.Encoding.UTF8);
   WriteRSSPrologue(writer);
   var homeUrl 
= HTTP+Request.ServerVariables["HTTP_HOST"+ "/home.aspx"//注意问题有可能出现的地方
   WriteRSSHeadChennel(writer,homeUrl);
   var nodeList 
= GetAllRssNodeList();
   
foreach (var item in nodeList)
   {
     var doc 
= new Document(item.Id);
     var description 
= doc.getProperty("Bodytext").Value.ToString();
     AddRSSItem(writer, item.UpdateDate.ToString(
"R"), item.Parent.Name, item.Name, HTTP + Request.ServerVariables["HTTP_HOST"+ umbraco.library.NiceUrl(item.Id), description);
    }
          
    writer.Flush();
    writer.Close();
    context.Response.ContentEncoding 
= System.Text.Encoding.UTF8;
    context.Response.ContentType 
= "text/xml";
    context.Response.Cache.SetCacheability(HttpCacheability.Public);
    context.Response.End();
}
private XmlTextWriter WriteRSSPrologue(XmlTextWriter writer)
{
   writer.WriteStartDocument();
   writer.WriteStartElement(
"rss");
   writer.WriteAttributeString(
"version""2.0");
   writer.WriteAttributeString(
"xmlns:content""http://purl.org/rss/1.0/modules/content/");
   writer.WriteAttributeString(
"xmlns:wfw""http://wellformedweb.org/CommentAPI/");
   writer.WriteAttributeString(
"xmlns:dc""http://purl.org/dc/elements/1.1/");
   
return writer;
}
private XmlTextWriter WriteRSSHeadChennel(XmlTextWriter writer,string homeUrl)
{
   writer.WriteStartElement(
"channel");
   writer.WriteElementString(
"title""MeubelTrack - Rss");
   writer.WriteElementString(
"copyright""Copyright (c) 2009,www.tribal.cn");
   writer.WriteElementString(
"link", homeUrl);
   writer.WriteElementString(
"generator""Tribal");
   writer.WriteElementString(
"description""Meubeltrack.nl - dé route naar uw meubels");
   
return writer;
}
private XmlTextWriter AddRSSItem(XmlTextWriter writer, string pubDate,string sItemCategory, string sItemTitle, string sItemLink, string sItemDescription)
{
   writer.WriteStartElement(
"item");
   writer.WriteElementString(
"title", sItemTitle);
   writer.WriteElementString(
"link", sItemLink);
   writer.WriteElementString(
"description", HttpUtility.HtmlDecode(sItemDescription));
   writer.WriteElementString(
"pubDate", pubDate);
   writer.WriteElementString(
"category", sItemCategory);
   writer.WriteElementString(
"author""tribalChina");
   writer.WriteEndElement();
   
return writer;
}