1

Basically I am trying to use the new MVC5 routing attribute to redirect /sitemap.xml to a method as I need to dynamically create it.

// GET: /sitemap.xml
[Route("sitemap.xml")]
public ActionResult SiteMap()
{
    // Stuff
}

At the moment that doesn't work so is it possible to do it like this or will I have to use the routing table like I did before?

routes.MapRoute(
   name: "Site Map",
   url: "sitemap.xml",
   defaults: new { controller = "Default", action = "SiteMap" });
tereško
  • 58,060
  • 25
  • 98
  • 150
David Ford
  • 513
  • 2
  • 12

1 Answers1

2

Add this to your web.config:

 <system.webServer>
 <handlers>
      <add name="ManagedDllExtension" path="*.xml" verb="GET" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
</system.webServer>
L01NL
  • 1,753
  • 1
  • 13
  • 17