Вопрос

My requirement is to pass a value, as a parameter, in a ServiceStack route which includes a slash like this 'SK-LOT-79-14/3/11' so I can fetch the records in my service.

Example route configuration:

[Route("/cims/qcHistoryByLot/{lotNumber}", "GET")]

Example lot number: SK-LOT-79-14/3/11

Это было полезно?

Решение

You simply need to add a * to the end of your route parameter.

[Route("/cims/qcHistoryByLot/{lotNumber*}", "GET")]
public class GetQcHistoryByLot
{
    public string LotNumber { get; set; }
}

Using the asterisk * acts as a wildcard and will capture anything after /cims/qcHistoryByLot/ into LotNumber. See wildcard paths in the routing documentation for more information.

This will work for routes where you are passing the slash in the last route parameter. If you require to pass a slash in a parameter that does not come last on the route, then you will need to handle encoding the value. See my other answer here.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top