/r is removed from string parameter
-
Hi all, I am passing a string parameter to one of the method of web service. This string parameter has /r and/n incorporated in it, but when value is passed to web service it removes /r from it. Any reason why is it happening so. Web service is created using .Net framework 1.1 and written in C# code. I am trying to consume web service in an another application build using framework 1.1. Rock Star
-
Hi all, I am passing a string parameter to one of the method of web service. This string parameter has /r and/n incorporated in it, but when value is passed to web service it removes /r from it. Any reason why is it happening so. Web service is created using .Net framework 1.1 and written in C# code. I am trying to consume web service in an another application build using framework 1.1. Rock Star
Do you have the source code of that web service? Is it running on some OS where new lines are not
\r\n
but\n
only? (Assuming that you actually meant \r and \n when you wrote /r and /n...) -
Hi all, I am passing a string parameter to one of the method of web service. This string parameter has /r and/n incorporated in it, but when value is passed to web service it removes /r from it. Any reason why is it happening so. Web service is created using .Net framework 1.1 and written in C# code. I am trying to consume web service in an another application build using framework 1.1. Rock Star
If you want to have the \r and \n come across as literals (not return and newline), then you need to escape them before they get to the server. You can do this in two ways, either:
string escapedString = "This is my escaped \\r and escaped \\n value";
or
string escapedString = @"This is my escaped \r and escaped \n value";
-
Hi all, I am passing a string parameter to one of the method of web service. This string parameter has /r and/n incorporated in it, but when value is passed to web service it removes /r from it. Any reason why is it happening so. Web service is created using .Net framework 1.1 and written in C# code. I am trying to consume web service in an another application build using framework 1.1. Rock Star
Probably depends on what "parameter" means but presuming that you really do have a web 'method' and you are passing data in the body, not url, and the server is discarding it then there is nothing that you can do on the client side that will stop that unless you can find a server side feature that allows it. As per the other suggestion the server might allow escaping but that won't help unless it actually converts the value to the appropriate character. If it doesn't then it will return with the escape intact which won't help you. Of course if you can modify the server then that would solve it.