Simple scenario:
public IHttpActionResult Get()
{
return Ok<string>("I am send by HTTP resonse");
}
returns:
"I am send by HTTP resonse"
Just curious, can I avoid the quotation mark in other words return:
I am send by HTTP resonse
or is this necessary in HTTP?
' You can put a backslash character followed by a quote ( \" or \' ). This is called an escape sequence and Python will remove the backslash, and put just the quote in the string.
String values must be enclosed in single or double quote marks. For variables such as [$END_USER$ sting values enclosed in double quote marks are resolved, whereas those enclosed in single quote marks are kept as-is.
To place quotation marks in a string in your code In Visual C# and Visual C++, insert the escape sequence \" as an embedded quotation mark.
Yes you can avoid the "
public class ValuesController : ApiController
{
public string Get()
{
return "qwerty";
}
}
now check http://localhost:3848/api/values
and response
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">qwerty</string>
The result with <string>
tag but without quotes :)
EDIT
If you don't like this approach,try this.It returns just text
public HttpResponseMessage Get()
{
string result = "Your text";
var resp = new HttpResponseMessage(HttpStatusCode.OK);
resp.Content = new StringContent(result, System.Text.Encoding.UTF8, "text/plain");
return resp;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With