提前致谢解决方案 看看这里: http:// answers.yahoo.com/question/index?qid= 20081013154604AA6juCY [ ^ ] 我更改了UriTemplate,如下所示。 [OperationContract] [WebInvoke(Method =GET) , ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate =登录?name = {username }& pwd = {密码})] 流GetLogin(字符串用户名,字符串密码); 我将参数转换为Url编码格式并传递给我们的方法。以前我正在通过 UriTemplate作为UriTemplate =Login / {username} / {pwd}。现在我改为 UriTemplate =登录?name = {username}& pwd = {password}所以这次它被视为查询字符串。所以我们将在方法中获得正确的参数值。 /> 注意:你应该只传递参数Url编码格式 Hi, I create a wcf project. In this Project I used GetLogin(string username, string pwd) for getting login details. I typed in browser One parameter (password) like ratheesh123# this. It contains # values. Here I am getting ratheesh123 only, "#" can''t get in my wcf project. [OperationContract] [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "Login/{username}/{pwd}")] Stream GetLogin(string username,string pwd);any one help....Hash(#) not getting as input values in any methods that are written in wcfHow url encoding works in wcf applicationsThanks in advance 解决方案 Hi,Have a look here:http://answers.yahoo.com/question/index?qid=20081013154604AA6juCY[^]I changed the UriTemplate as like follows.[OperationContract] [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "Login?name={username}&pwd={password}")] Stream GetLogin(string username,string password);I convert to Parameter to Url Encoded format and passing to our methods. Previously i am passing UriTemplate as UriTemplate = "Login/{username}/{pwd}". now i changed to UriTemplate = "Login?name={username}&pwd={password} so this time it is treated as querystring. so we will get correct parameter values in methods.Note. you should pass parameter Url Encoded format only 这篇关于wcf中查询字符串中的hash(#)不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-22 04:56