I want to redirect each call on a website made for www.domain.com/sitemap.xml to a controller action. How can I achieve this?
I've got this till so far, but the statuscode returned is an 302. I want to return an 200 status with it, but still redirect / rewrite to an controller action. The reason i'm asking is that I want each call for the mentioned url redirected to a controlleraction. The controller does some foo en generates an xml sitemap. Then the output of this controlleraction needs to be returned.
protected void Application_BeginRequest()
{
//Check if an call for the sitemap.xml has been made
if (Request.Path == "/sitemap.xml")
{
Response.RedirectToRoute("XmlSitemap");
}
}