uhaciogullari / SimpleMvcSitemap

A minimalist library for creating sitemap files inside ASP.NET MVC and ASP.NET Core MVC applications
MIT License
128 stars 39 forks source link

Not generating xsi:schemaLocation= or xmlns= attributes! #47

Closed FrancescoBonizzi closed 3 years ago

FrancescoBonizzi commented 3 years ago

Hi! Thanks for your very useful tool, but I have a little problem!

My sitemap gets generated without any attributes on the url element. You can see it here generated in real time.

The cose I used:

[Route(template: "sitemap.xml")]
public IActionResult SitemapXml()
{
    var routes = _routesInspector.AllRoutes;
    var nodes = new List<SitemapNode>();
    foreach (var section in routes)
    {
        foreach (var route in section.Value)
        {
            nodes.Add(new SitemapNode(Url.Content(route.Url)));
        }
    }

    return new SitemapProvider().CreateSitemap(new SitemapModel(nodes));
}

Do I missed something? I noticed it because Google Search Console says it cannot read it!

Thanks.

uhaciogullari commented 3 years ago

Hi Francesco

What attributes are you missing? You can specify the optional attributes like described here. Your link doesn't work but the sitemap on https://www.imaginesoftware.it/sitemap.xml looks valid to me.

FrancescoBonizzi commented 3 years ago

Hi and thanks for answering. I fixed the link. I think I'm a little stupid as I noticed that Firefox has an integrated viewer that removed the attribute.

Thanks!