I have a Flash based component that insists on asking for an XML settings file in whatever "directory" I am currently in.
That means it's asking for paths like...
/Home/mysettings.xml
/Home/Record/mysettings.xml
/AnotherController/AnotherAction/mysettings.xml
This is annoying. I'm trying to create an MVC route to catch anything with mysettings.xml
and send them to a static action. I've created a view for the XML and it's possible I'll need to swap the variables on the fly (using URL queries of some kind, probably).
Here is a first stab in my Global.asax.cs
:
routes.MapRoute(
"XmlOverride",
"mysettings.xml",
new { controller = "Home", action = "MyXML" }
);
But I'm missing something. It's either 404ing or not going to the right location no matter what I do to it. Is there a way I can get it to route to the right action? Can I preserve the URL vars in the process?
Thanks!
Update
I have a hacked up version working like this. I'm not sure it's the best way to go, but it seems to work. Does anyone have better solutions?
routes.MapRoute(
"XmlOverride",
"{c}/mysettings.xml",
new { controller = "Home", action = "MyXML" }
);
routes.MapRoute(
"XmlOverride+Action",
"{c}/{a}/mysettings.xml",
new { controller = "Home", action = "MyXML" }
);
You can't use {controller}
or {action}
because it's at a fixed path.