0

I have the following link:

@Html.ActionLink("Order", "OrderProduct", 
new { controller = "Orders", id = item.ITEMID }, 
new { @class = "lightbox order-link" })

My item.ITEMID id could contain a forwardslash, for example: GT25-1/VS

But when I click on the link, the id in my controller is only GT25-1

public ActionResult OrderProduct(string id)

Is there a way I can encode this value to include everything and then decode it in my action?

CallumVass
  • 11,288
  • 26
  • 84
  • 154

1 Answers1

0

Try encoding your id when creating your url, e.g.

@Html.ActionLink("Order", "OrderProduct", 
new { controller = "Orders", id = HttpUtility.UrlEncode(item.ITEMID) }, 
new { @class = "lightbox order-link" })

you might need/want to decode in your action then

id = HttpUtility.UrlDecode(id);
dove
  • 20,469
  • 14
  • 82
  • 108