In MVC 5.2.2 I can set Routes.AppendTrailingSlash
to true so that trailing slash are appended to urls.
However I also have a robots controller which returns the content for the robots.txt.
How can I prevent a Slash from being appended to the robots.txt route and have it callable with out the trailing slash?
My Controller code:
[Route("robots.txt")]
public async Task<ActionResult> Robots()
{
string robots = getRobotsContent();
return Content(robots, "text/plain");
}
My Route Config looks like this:
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home",
action = "Index",
id = UrlParameter.Optional }
);
RouteTable.Routes.AppendTrailingSlash = true;