Click here to Skip to main content
13,199,311 members (65,787 online)
Rate this:
 
Please Sign up or sign in to vote.
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.
[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 9-Feb-13 0:40am
Updated 11-Feb-13 23:08pm
v3
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web03 | 2.8.171020.1 | Last Updated 13 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100