2
我試圖用Response.Write
使用ASP.NET輸出我自己的RSS源。程序代碼本身不會導致錯誤/異常。但是當使用Response.Write
輸出時,我在JS腳本HttpErrorpagesscript
中收到錯誤。我收到的錯誤是Runtime error Microsoft JScript: Unspecified Error
。Response.Write(RSS)導致Javascript異常:「未指定的錯誤」(IIS 7.5)
它發生在下面一行:
function initMoreInfo(infoBlockID)
{
var bElement = document.createElement("A");
bElement.innerText = L_MOREINFO_TEXT; <--- Break happens here
bElement.href = "javascript:expandCollapse(\'infoBlockID\', true);";
moreInfoContainer.appendChild(bElement);
}
我不知道錯誤的由來所以我將提供C#輸出的XML。
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
StringBuilder builder = new StringBuilder();
using (XmlWriter writer = XmlWriter.Create(builder, settings))
{
// Write startelement
writer.WriteStartDocument();
//Write elementRSS
writer.WriteStartElement("rss");
//Write channel
writer.WriteStartElement("channel");
//Write title
writer.WriteElementString("title","RSS-Feed svranken");
//Write Ttl
writer.WriteElementString("ttl","1");
foreach (SyndicationItem rssItem in syndFeed.Items.OrderByDescending(x => x.PublishDate).Take(25))
{
writer.WriteStartElement("item");
//Write Elements
writer.WriteElementString("PubDate", rssItem.PublishDate.ToString("yyyy-MM-dd HH:mm:ss"));
writer.WriteElementString("title", rssItem.Title.Text);
writer.WriteElementString("description", rssItem.Summary.Text);
writer.WriteElementString("link", rssItem.Id.ToString());
writer.WriteEndElement();
}
writer.WriteEndElement();
writer.WriteEndElement();
writer.WriteEndDocument();
}
Response.AddHeader("Content-Type", "text/xml");
Response.Write(builder.ToString());
有沒有人發現錯誤?我在這裏錯過了什麼?
謝謝您的時間
注:我上面提供的JavaScript是不是我的解決方案的一部分。我認爲它是由我的本地IIS自動生成的。
UPDATE: IISExpress產生相同的錯誤所行的Visual Studio開發服務器