开发者

Create an Dynamic XML file which is actually an ASPX page?

开发者 https://www.devze.com 2023-01-07 07:37 出处:网络
Is it possible to create a sitemap.xml file which is dynamic and is actually created each time it is requested using c#

Is it possible to create a sitemap.xml file which is dynamic and is actually created each time it is requested using c#

The开发者_运维百科 obvious thing to do would be to call the file sitemap.aspx and have it return XML, but it has to be called sitemap.xml and look like an XML file (headers etc) to the requester.


Try creating a generic handler, sitemap.ashx file that returns the XML. Then rename it to sitemap.xml. Make sure you set the content type to xml:

context.Response.ContentType = "text/xml";

Then in IIS, you would have to map the xml file extension to the ASP.NET engine.

I'm not 100% sure it'll work since it's a .xml extension, but it's worth trying if you really want to show the .xml extension to the user.

0

精彩评论

暂无评论...
验证码 换一张
取 消