Reputation: 11
public string Get()
{
return "a <br /> b";
}
How to add a line break to a string that will be used in Get() at Web API ASP.Net?
I tried some solutions below, but it didn't give me a line break.
return " a \n b";
return "a \r\n b";
return "a" + Environment.Newline (not sure about the spelling of newline) + "b";
return "a <br/> b";
return "a <br /> b";
return "a <br> b";
Just to be sure, its not HttpRequest that I'm trying to get, it's a string. Please and thank you.
Code
Upvotes: 0
Views: 4309
Reputation: 1716
"a \n b"
and Environment.NewLine
will give you new line break, I tested it with chrome.
result:
if you want to return HTML string text using beak with <br />
you need to return it as ContentResult
public ContentResult Get()
{
return new ContentResult
{
ContentType = "text/html",
Content = "a <br /> b"
};
}
with HTML result:
Upvotes: 2