wcf中查询字符串中的hash(#)不起作用 [英] hash(#) in query string in wcf not working
本文介绍了wcf中查询字符串中的hash(#)不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个wcf项目。在这个项目中,我使用GetLogin(字符串用户名,字符串pwd)来获取登录详细信息。我在浏览器中键入了一个参数(密码),如ratheesh123#this。它包含#值。在这里我只得到了ratheesh123,#无法进入我的wcf项目。
[OperationContract]
[WebInvoke(Method = GET,
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = 登录/ {username} / {pwd})]
流GetLogin( string 用户名, string pwd);
任何一个帮助....
哈希(#)没有得到任何用wcf编写的方法的输入值
如何在wcf应用程序中使用url编码>
提前致谢
解决方案
看看这里:
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 wcf
How url encoding works in wcf applications
Thanks 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(#)不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文