2013-09-04 1 views
0

샘플 메시지 : 로그인 = 관리자 & 암호 = 암호 & TranId =다음 예제 메시지를 쿼리 문자열로 보내려면 어떻게합니까?

9220 내가

[OperationContract(Name = "GetSampleMethod")] 
     [WebGet(UriTemplate = "GetSampleMethod/inputStr/{data}")] 
     string GetSampleMethod(string data); 

난 그냥 하나의 문자열을 보낼 수 있어요 다음과 같은 방법으로 WCF 서비스가 = 0617759203 & TranType/Service.svc/GetSampleMethod/inputstr/abc 데이터로.

A potentially dangerous Request.Path value was detected from the client (&).

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: A potentially dangerous Request.Path value was detected from the client (&).

소스 오류 :

처리되지 않은 예외가 현재 웹 요청을 실행하는 동안 생성 된 나는 다음과 같은 오류를 얻고있다 데이터로 샘플 메시지를 보내려고합니다. 예외의 출처와 위치에 관한 정보는 아래의 예외 스택 추적을 사용하여 식별 할 수 있습니다.

스택 추적 :

[HttpException (0x80004005): A potentially dangerous Request.Path value was detected from the client (&).]
System.Web.HttpRequest.ValidateInputIfRequiredByConfig() +9672068
System.Web.PipelineStepManager.ValidateHelper(HttpContext context) +53

이 사람이 좀 도와 주 시겠어요? 이 유형의 메시지를 쿼리 문자열로 보내려면 어떻게해야합니까?

+0

보기 : http://stackoverflow.com/a/6026291/1879286 –

답변

0

쿼리 문자열에서 보내는 값을 HTTP 인코딩해야합니다. 즉, "& TranId = 0617759203"은 (공백을 뺀) "& amp; TranIDTranId = 0617759203"이되어 http를 통해 전송 될 수 있습니다.

+0

브라이언. 샘플 코드를 제공해 주시겠습니까? 도움이 될 것입니다. – RookieRoll

+0

String sQueryString = System.Web.HttpUtility.HtmlEncode (여기에 쿼리 문자열); – Brian

관련 문제