서비스 스택 3.9.21 사용. IIS 7.5에서 응용 프로그램 호스팅. 통합 된 4.0.30319 ASP.NET 응용 프로그램 풀 사용URL 매개 변수가없는 URL로 된 경로 매개 변수
그림 목적의 내가 다음 경로 (즉,이 DTO와 해당 요청 처리기에 의해 백업됩니다)가 있다고 가정 할 경우 :
일부 자동차 'IDS 내가 생각 그들에 문자가/cars/{id}
이 URL해야을 encoded - pipe, |는 그 중 하나입니다. 나는의 예를 들어 ID로 차를 가져 오기 위해 요청을 보낼 때 '1 | 2'나는 다음과 같은 스택 추적과 함께 좋은 오래된 (500)를 얻을 :
[ArgumentException]: Illegal characters in path.
at System.IO.Path.CheckInvalidPathChars(String path)
at System.IO.Path.GetFileName(String path)
at ServiceStack.MiniProfiler.UI.MiniProfilerHandler.MatchesRequest(IHttpRequest request) in C:\src\ServiceStack\src\ServiceStack\MiniProfiler\UI\MiniProfilerHandler.cs:line 24
at ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated) in C:\src\ServiceStack\src\ServiceStack\WebHost.Endpoints\ServiceStackHttpHandlerFactory.cs:line 153
at System.Web.HttpApplication.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
나는 관계없이이 얻을 난에 파이프를 인코딩 할 URL 여부 경로 또는 아닙니다. 이 문제를 어떻게 해결할 수 있습니까?
자세한 내용
using ServiceStack.ServiceHost;
namespace SSUEB
{
[Route("/cars/{id}", "GET")]
public class ById
{
public string Id { get; set; }
}
}
엔드 포인트
using System.Collections.Generic;
using System.Net;
using ServiceStack.Common.Web;
using Stack = ServiceStack.ServiceInterface;
namespace SSUEB
{
public class Cars : Stack.Service
{
public object Get(ById byId)
{
return new HttpResult(new Dictionary<string, string> {{"id", byId.Id}}, HttpStatusCode.OK);
}
}
}
앱
DTOusing ServiceStack.WebHost.Endpoints;
namespace SSUEB
{
public class SSUEB : AppHostBase
{
public SSUEB() : base("ServiceStack toy service", typeof(SSUEB).Assembly)
{
}
public override void Configure(Funq.Container container)
{
ServiceStack.Text.JsConfig.EmitCamelCaseNames = true;
SetConfig(new EndpointHostConfig { DebugMode = true });
}
}
}
는 요청
이 하나
curl -v -X GET -H "Accept: application/json" http://localhost:80/dealership/cars/123%20456
가 예상 200 응답 가져옵니다 :
{"id":"123 456"}
을하지만이 하나
curl -v -X GET -H "Accept: application/json" http://localhost:80/dealership/cars/123%7C456
은 원래보고 된 문제가됩니다.
IIS 요청 로그은 % 7C가 파이프로 디코딩되고 % 20이 (로그에서 적어도 더하기로) 디코딩됨을 보여줍니다. 후자는 200 (OK) 응답, 이전은 500 (내부 서버 오류)입니다. 이 IIS에서 유효하지 않은 문자를 허용하는 방법에 Scott Hanselman's post를 참조 ASP.NET에 의해 생성 된 사전 검증 예외입니다으로
2012-12-03 22:21:20 127.0.0.1 GET /dealership/cars/123|456 - 80 - 127.0.0.1 curl/7.27.0 500 0 0 5
2012-12-03 22:21:25 127.0.0.1 GET /dealership/cars/123+456 - 80 - 127.0.0.1 curl/7.27.0 200 0 0 1
요청 DTO, 경로 정의 및 HTTP 요청을 게시 할 수 있습니까? – mythz
요청한 세부 정보를 추가했습니다. 솔루션을 기다리는 중 : D. – gv0tch0
안녕하세요. @mythz - 요청한 정보를 게시했습니다. 한번보세요. 기회가 있었습니까? 아마 내가 github에 문제로 게시해야합니까? – gv0tch0