tags:

views:

52

answers:

2

I'm an absolute beginner with ASP.NET[MVC] so this is probably a dumb question.

I want to wire-up a url "http://localhost/clientaccesspolicy.xml" to a specific controller action. How could I go about doing this?

I'm also wondering how to just statically serve a file for this url.

(I was able to statically serve the file by adding it as a 'Content' file at the top level of the project).

+1  A: 

You could accomplish this adding:

routes.RouteExistingFiles = true;

above all your other routes. Then add:

routes.MapRoute(null, "clientaccesspolicy.xml", new { controller = "Foo", action = "Whatever" });

That should work but I will warn you, this is generally not a very good idea. What this does is tell the MVC routing system to stop serving files that match on the disk. This will include your images, css, scripts, etc. This will make much more work for you than it will save I imagine.

DM
+2  A: 

This should do, so all your other routes remain untouched... And you don't need a controller action for this..

routes.RouteExistingFiles = true;

routes.IgnoreRoute("clientaccesspolicy.xml");
David