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

推荐订阅源

B
Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
B
Blog RSS Feed
云风的 BLOG
云风的 BLOG
G
Google Developers Blog
Recent Announcements
Recent Announcements
A
About on SuperTechFans
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Google Online Security Blog
Google Online Security Blog
Google DeepMind News
Google DeepMind News
S
Schneier on Security
S
Secure Thoughts
T
The Exploit Database - CXSecurity.com
Martin Fowler
Martin Fowler
P
Proofpoint News Feed
Security Latest
Security Latest
Jina AI
Jina AI
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Recorded Future
Recorded Future
T
Tor Project blog
有赞技术团队
有赞技术团队
H
Hackread – Cybersecurity News, Data Breaches, AI and More
N
News | PayPal Newsroom
博客园 - 三生石上(FineUI控件)
MyScale Blog
MyScale Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
Forbes - Security
Forbes - Security
D
DataBreaches.Net
人人都是产品经理
人人都是产品经理
NISL@THU
NISL@THU
C
Cisco Blogs
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Google DeepMind News
Google DeepMind News
Project Zero
Project Zero
IT之家
IT之家
T
Threatpost
Cyberwarzone
Cyberwarzone
O
OpenAI News
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
J
Java Code Geeks
P
Proofpoint News Feed
The Last Watchdog
The Last Watchdog
月光博客
月光博客
Latest news
Latest news
MongoDB | Blog
MongoDB | Blog
Apple Machine Learning Research
Apple Machine Learning Research

博客园 - 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;
}