Transfer sitemap.xml http request to route handler in ASP.NET MVC?

If you want to route to and action instead to a request handler.

Up vote 0 down vote favorite 1 share g+ share fb share tw.

I'm trying to add a route that will transfer all sitemap. Xml requests to a custom request handler I made. I tried using the following code: routes.

Add(new Route("sitemap. Xml", new Helpers. SiteMapRouteHandler())); routes.

MapRoute( "Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = "" } ); But when I make a link using Url.Action(): Url. Action("Index", new { controller = "About"}) I get the following when I try to navigate to the XML file: /sitemap. Xml?

Action=Index&controller=About What am I doing wrong? ANSWER: I used this solution: Specifying exact path for my ASP.NET Http Handler asp.net-mvc asp.net-mvc-2 asp.net-mvc-routing link|improve this question edited Feb 8 '11 at 9:56 asked Feb 7 '11 at 13:32Shay1245 45% accept rate.

It appears pretty generic, so it would be matching on all requests. You may want to use Phil Haack's Route Debugger to help you out. – Jonathan Bates Feb 7 '11 at 15:58.

If you want to route to and action instead to a request handler You could add a route like this routes. MapRoute( "Sitemap", "sitemap. Xml", new { controller = "Home", action = "SiteMap" } ); as mentioned here - MVC: How to route /sitemap.

Xml to an ActionResult? And it worked for me.

Works great, thanks! – the_lotus Feb 28 at 20:01.

I'm not sure if this will solve the problem, but it's worth a try: routes. Add( new Route( "{request}", new RouteValueDictionary(new { id = "" }), // this might be the tricky part to change new RouteValueDictionary(new { request = "sitemap. Xml" }), new Helpers.

SiteMapRouteHandler() )).

No, it doesn't work. I get HTTP 404 when trying to get /sitemap. Xml – Shay Feb 7 '11 at 14:11 Wish I could have been more help.

Only other thing I can think of is to try setting both RVD to (new { request = "sitemap. Xml" }) – ARM Feb 7 '11 at 15:16.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions