I know if I want to get the current action I can use;
ControllerContext.RouteData.GetRequiredString("action")
However what if my route allowed http://mydomain/this has spaces
How would I get “This Has Spaces” rather than “ThisHasSpaces“?
Here is a snippet from my route table
routes.MapRoute(
"ThisHasSpaces", // Route name
"This Has Spaces", // URL with parameters
new { controller = "Home", action = "ThisHasSpaces", id = UrlParameter.Optional } // Parameter defaults
);
If your route looks like that there’s nothing that can give you the original string (other than
Request.Uri) since you do not actually map the uri to a route parameter.Since you hardcode the route you could add another value:
And fetch it: