Reputation: 912
Edit: It seems like there is trouble with my Routeconfig.cs. When I removed everything except the most basic routing I can find my sitemap.xml. I'll investigate and come back with an answer.
-
I have installed MvcSiteMapProvider.MVC4 through Nuget in my MVC4 project.
My Mvc.sitemap looks like this (it's as I got it through Nuget)
<?xml version="1.0" encoding="utf-8" ?>
<mvcSiteMap xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-4.0"
xsi:schemaLocation="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-4.0 MvcSiteMapSchema.xsd">
<mvcSiteMapNode title="Home" controller="Home" action="Index">
<mvcSiteMapNode title="About" controller="Home" action="About"/>
</mvcSiteMapNode>
</mvcSiteMap>
I have corresponding controllers and actions in my project (although my Homecontroller has more actions which I havn't writted out in the schema)
At the bottom of my RouteConfig.cs I added this like
MvcSiteMapProvider.Web.Mvc.XmlSiteMapController.RegisterRoutes(routes);
Everything compiles fine and I have made no other alterations to the code.
But when I go to localhost:xxxx/sitemap.xml I find no file (The resource cannot be found.). I was under the impression that this would work out of the box. Am I missing something?
Other things MvcSiteMapProvider does like @Html.MvcSiteMap().SiteMap() works just fine, but it simply does not generate the sitemap.xml.
Upvotes: 1
Views: 2588
Reputation: 912
There was a format error in my RouteConfig.cs file and the MVC route-parser simply stopped before it reached the critical code:
MvcSiteMapProvider.Web.Mvc.XmlSiteMapController.RegisterRoutes(routes);
Make sure your RouteConfig.cs isn't stopping halfway and it should be fine.
So it was all my fault.
Upvotes: 3