我正在尝试在我的 aspx 页面上输出 xml。但它不返回任何结果。
aspx 页面:
<%@ Page Language="C#" AutoEventWireup="false" CodeBehind="Sitemap.aspx.cs"
Inherits="Servicebyen.Presentation.Web.Sitemap" %>
后面的代码:
protected void Page_Load(object sender, EventArgs e)
{
Response.Clear();
Response.ContentType = "text/xml";
var writer = new XmlTextWriter(Response.OutputStream, Encoding.UTF8);
writer.Settings.CloseOutput = false;
writer.WriteStartDocument();
writer.WriteStartElement("urlset");
writer.WriteAttributeString("xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9");
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Flush();
writer.Close();
Response.End();
}
你能看出这有什么问题吗?