[英]How to pass the parameters to WCF Web Service with special characters?
我正在使用WCF和C#。
我必须使用特殊字符(例如Email-ram@gmail.com和Password-Test @ 123)将参数传递给WCF Web服务
传递参数时,得到错误“404 Not Found”,如果传递参数没有特殊字符,则它正在工作。
工作
localhost:35798/RestServiceImpl.svc/LoginRequest/ram/Test123/1223
不工作
localhost:35798/RestServiceImpl.svc/LoginRequest/ram@gmail.com/Test@123/1223
可能吗?
/** 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);
检查下面的CDATA链接希望它有所帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.