We had a route defined as
routes.MapRoute(
name: "SearchFor",
url: "Search/For/{text}",
defaults: new
{
controller = "Search",
action = "For",
text = UrlParameter.Optional
}
Following a new customer whose data happened to contain lots of forward slashes we had a problem with text
such as item/1
. To get around this the route was updated include a catch all as follows
routes.MapRoute(
name: "SearchFor",
url: "Search/For/{*text}",
defaults: new
{
controller = "Search",
action = "For",
text = UrlParameter.Optional
}
However this doesn't help if the text
contains a leading space to the forward slash e.g. item /1
which causes IIS to return a 404 error.
Is it possible to get around this issue without encoding the text parameter in some manner?