Unfortunately I need to accept a route parameter with an & in it. I have this route definition. The id parameter will sometimes have an & in it like this X&Y001.
routes.MapRoute(
"AffiliateEdit",
"Admin/EditAffiliate/{*id}",
new { controller = "UserAdministration", action = "EditAffiliate", id = ""}
);
I have tried working around this issue in the following ways however none of them have worked. All of these result in an HTTP 400 Bad Request error in the browser.
<a href="/Admin/EditAffiliate/<%= a.CustomerID.Replace("&", "%26") %>">Edit</a>
This gives me <a href="/Admin/EditAffiliate/X%26Y001">Edit</a>
<%= Html.RouteLink("Edit", "AffiliateEdit", new { id = a.CustomerID }) %>
This gives me <a href="/Admin/EditAffiliate/X&Y001">Edit</a>
<%= Html.RouteLink("Edit", "AffiliateEdit", new { id = Url.Encode(a.CustomerID) }) %>
This gives me <a href="/Admin/EditAffiliate/X%2526Y001">Edit</a>