Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 当RSS提要中存在查询字符串时,如何对自链接进行编码_Asp.net_Url_Rss_Encode - Fatal编程技术网

Asp.net 当RSS提要中存在查询字符串时,如何对自链接进行编码

Asp.net 当RSS提要中存在查询字符串时,如何对自链接进行编码,asp.net,url,rss,encode,Asp.net,Url,Rss,Encode,我正在为我的一些页面动态生成RSS提要 问题是页面在URL中包含一个查询字符串以生成内容。当我将此URL放入标记时 此示例代码具有相同的问题,可以进行验证 RSS源 http://localhost/?id=1&title=sample SO的样本项目 EN website@localhost(网站管理员) 5. 第1页 http://localhost/page1 http://localhost/page1 2011年1月25日星期二11:44:41 GMT 问题似乎与第二个查询字符串参

我正在为我的一些页面动态生成RSS提要

问题是页面在URL中包含一个查询字符串以生成内容。当我将此URL放入标记时

此示例代码具有相同的问题,可以进行验证


RSS源
http://localhost/?id=1&title=sample
SO的样本项目
EN
website@localhost(网站管理员)
5.
第1页
http://localhost/page1
http://localhost/page1
2011年1月25日星期二11:44:41 GMT
问题似乎与第二个查询字符串参数有关。但是,如果我对URL进行完整编码,它是无效的


我正在使用asp.net MVC生成页面,并使用
Request.Url
获取当前提要Url。有30多个可能的参数,所以使用URL重写来绕过这个问题不是一个可行的解决方案

解决方案是只对查询字符串进行编码,而不是对整个url进行编码。这使得提要有效

<rss version="2.0"  xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>RSS Feed</title>
    <link>http://localhost/?id=1&title=sample</link>
    <atom:link href="http://localhost/?id=1&title=sample" rel="self" type="application/rss+xml" />
    <description>Sample Items for SO</description> 
    <language>en</language>
    <copyright></copyright>
    <webMaster>website@localhost (webmaster)</webMaster>
    <ttl>5</ttl>
    <item>
        <title>Page 1</title>
        <link>http://localhost/page1</link>
        <guid>http://localhost/page1</guid>
        <description></description>
        <pubDate>Tue, 25 Jan 2011 11:44:41 GMT</pubDate>
    </item>
  </channel>
</rss>