[英]How to pass the parameters to WCF Web Service with special characters?
I'm using WCF with C#. 我正在使用WCF和C#。
I have to pass the parameters to WCF web service with special characters like- Email-ram@gmail.com and Password-Test@123 我必须使用特殊字符(例如Email-ram@gmail.com和Password-Test @ 123)将参数传递给WCF Web服务
While passing the parameters, got error "404 Not Found" and if passed parameters without special characters it's working. 传递参数时,得到错误“404 Not Found”,如果传递参数没有特殊字符,则它正在工作。
Working 工作
localhost:35798/RestServiceImpl.svc/LoginRequest/ram/Test123/1223
Not Working 不工作
localhost:35798/RestServiceImpl.svc/LoginRequest/ram@gmail.com/Test@123/1223
Is it possible? 可能吗?
/** Code for the same **/
[OperationContract]
[WebInvoke(
Method = "POST",
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.WrappedRequest,
UriTemplate = "LoginRequest/{Email}/{Password}/{APPUID}")]
string LoginRequest(string Email, string Password, string APPUID);
public string LoginRequest(string Email, string Password, string APPUID)
{
string strResult = "";
if (Password.Trim() != null && Password.Trim() != "" && Email.Trim() != null && Email.Trim() != "")
{
strResult = " Success.";
}
else
{
strResult = "User name and password are required.";
}
return strResult;
}
您应该通过Html编码发送作为参数的部分:
var safeEmailParam = WebUtility.HtmlEncode(yourEMailParam);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.