I have a query that I'm sure I've already passed on to someone else. When rendering the view it always shows an empty line at the beginning and this generates the following error:
XML reading error: text or XML declaration in a different place from the beginning of the entity Location:
View: IndexSitemap.cshtml
<xsl:stylesheet version="2.0"
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
.
.
.
<body>
Controller:
public ActionResult MainSitemap()
{
Response.ClearHeaders();
Response.AddHeader("content-type", "text/xml");
//Response.AddHeader("content-type", "application/vnd.ms-excel");
return View("IndexSitemap");
}
Result:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
.
.
.
<body>
Thank you