【发布时间】:2016-03-11 11:10:43
【问题描述】:
我正在使用带有 C# 的 WCF。
我必须使用特殊字符将参数传递给 WCF Web 服务,例如 - Email-ram@gmail.com 和 Password-Test@123
在传递参数时,出现错误“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;
}
【问题讨论】:
-
你需要
HTMLEncode这些字符。
标签: c# web-services wcf wcf-data-services wcf-binding