문제

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