How can I keep the break line in my c# api?

I create a textarea in html. In the textarea you can have break line. When I check, if the value returns the break line, it’s good. But when I do that in my API

public string Put(string comment = "")
{
    return comment ;
}

To check again if I have the break line, there is no break line.

this is what I send to the API

Test
test

this is the response of the api

Testtest

Someone have any idea how can I resolve my issue ?

UPDATE

When I call my api in angularjs

$http.put('api/Test?comment=' + comment).then(function (response) {
    console.log(response.data)
})

With console.log(response.data) I see that my api remove break line but when I check console.log(comment) I see my line break.

UPDATE

I guess it have this is issue with the binding String, there is another binding or a solution for my issue ?

Answer

By constructing the query string yourself, you’re neglecting to encode the parameters. This will not only cause problems with newlines, but with any symbols that have special meanings in the query string (e.g. &, +). It looks like you can do this:

$http.put('api/Test', {}, {params: {comment: comment}}).then(function (response) {
    console.log(response.data)
});

You may also want to consider passing the comment in the body of your put rather than the URL. (Depending on your server-side technology, you may need to change your server-side code to make this work.)

$http.put('api/Test', {comment: comment}).then(function (response) {
    console.log(response.data)
});