Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
C#
[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
Posted
Updated 11-Feb-13 23:08pm
v3

 
Share this answer
 
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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900