Congratulations, you just found a bug in code that has been running for 10 years. I do not see any indication that you are using WCF. All I see is a URL.
The '%' is a special character in a URL. It is used to URL encode special characters. The standard solution in web dev is URL encoding data passed in the URL. Then URL decode the URL when fetching the data if needed.
You have not shared the code that creates the URL or fetches the data. This is where is the bug(s) are located in the code. Take a few minutes to run the code through the Visual Studio debugger. That's what the debugger is for...
Here's basic example of URL encoded the data.
Text%25123
URL encoding is very simple. This example assumes an ASP.NET application.
Member
60 Points
108 Posts
When using WCF the % in string is converted to wierd character
Oct 12, 2020 07:58 AM|KALYANA ALLAM|LINK
We call WCF to pass password the % is converted to a weird character
I passed test%123
test!3
(It not! exclamation but some weird character}
We use string to pass the password
All-Star
52971 Points
23566 Posts
Re: When using WCF the % in string is converted to wierd character
Oct 12, 2020 03:40 PM|mgebhard|LINK
You are doing something wrong but we cannot see the code. Please try running your code through the debugger.
Member
60 Points
108 Posts
Re: When using WCF the % in string is converted to wierd character
Oct 12, 2020 03:47 PM|KALYANA ALLAM|LINK
Hi mgebhard
This code was exisiting for 10 years this a WCF service AuthenticationService.svc calls the method Authenticate
When we use % the password is getting corruputed ,any ideas of usinhg escpae sequences
http://localhost/ AuthenticationService.svc/Authenticate?companyName=CLS&userName=techsupport@coresolutionsinc.com&Password=test%123&companyId=1&Cx360DeviceId=NA
I just pasted this in my Chrome browser
http://localhost/CSI.Cx360.Provider.Service.Data.Web.Consolidation/AuthenticationService.svc/Authenticate?companyName=CLS&userName=techsupport@coresolutionsinc.com&Password=test%423&companyId=1&Cx360DeviceId=NA
after submitting it reads
http://localhost/CSI.Cx360.Provider.Service.Data.Web.Consolidation/AuthenticationService.svc/Authenticate?companyName=CLS&userName=techsupport@coresolutionsinc.com&Password=testB3&companyId=1&Cx360DeviceId=NA
I am wondering how it convereted from test%423 to testB3
All-Star
52971 Points
23566 Posts
Re: When using WCF the % in string is converted to wierd character
Oct 12, 2020 04:16 PM|mgebhard|LINK
Congratulations, you just found a bug in code that has been running for 10 years. I do not see any indication that you are using WCF. All I see is a URL.
The '%' is a special character in a URL. It is used to URL encode special characters. The standard solution in web dev is URL encoding data passed in the URL. Then URL decode the URL when fetching the data if needed.
You have not shared the code that creates the URL or fetches the data. This is where is the bug(s) are located in the code. Take a few minutes to run the code through the Visual Studio debugger. That's what the debugger is for...
Here's basic example of URL encoded the data.
Text%25123
URL encoding is very simple. This example assumes an ASP.NET application.
Member
60 Points
108 Posts
Re: When using WCF the % in string is converted to wierd character
Oct 12, 2020 04:59 PM|KALYANA ALLAM|LINK
Thanks Mgebhard
The below cod fix worked for me , I used UrlEncoding and passed the password to WCF Service, it works now
string encodedPassword = HttpUtility.UrlEncode(password);
webAuthUrl = string.Format("{0}?companyName={1}&userName={2}&Password={3}&companyId=1&Cx360DeviceId=NA"
, ConfigurationManager.AppSettings["webAuthUrl"] + "Authenticate", companyCode, userName, encodedPassword);