I have a controller on my site that handles unknown actions and returns a view if it exists. This is so that static content can be added to this particular area of the site without having to modify the controller. The problem I am faced with now is to create a sitemap.xml file that contains links to all of these "unknown" views. What is the best method of enumerating these static content views from my method which is generating the site map?
The code below shows what I am doing for the unknown actions:
protected override void HandleUnknownAction(string actionName)
{
GetUnknownActionResult(actionName).ExecuteResult(ControllerContext);
}
[NonAction] //public so it is testable
public ActionResult GetUnknownActionResult(string actionName)
{
var result = View(actionName);
if (result.ViewEngineCollection.Any(engine => engine.FindView(ControllerContext, result.ViewName, null, true).View != null))
{
return result;
}
return new HttpNotFoundResult();
}