I am trying to output xml on my asp开发者_Go百科x page. But it returns no result.
The aspx page:
<%@ Page Language="C#" AutoEventWireup="false" CodeBehind="Sitemap.aspx.cs"
 Inherits="Servicebyen.Presentation.Web.Sitemap" %>
The code behinde:
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();
}
Can you see anything wrong with this?
If you are testing this out in Google Chrome then you will get a blank page is it doesn't render xml files well from websites.
Another thing to try is rather than implement this as a page implement it as a Generic Handler. This avoids the overhead of the Page Lifecycle for ASP.NET and reduces the places where errors can occur or mistakes can be made.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论