Our application consists of an angular frontend and a c# .net backend. We use textareas with characterlimits in the html file. Now to the problem:
In most places the text in the textarea is sent to the backend and written into the database without any problems, because for line-breaks only n gets used which is interpreted as one character.
In two cases we use the annotation [FromForm] in our Controllers, because we get an additional file from the frontend. The line-endings of the string-properties in these dtos become rn which is interpreted as two characters.
If we write a text in the frontend with x characters and send it to the backend which has the annotation [MaxLength(x)] on the property, the first case (n) is written into the database and the second case (rn) throws an error because the string is longer than it should be.
Is there a way to configure that all strings have the same line break(n)? We don’t want to use “hacks” by using string.replace or add some length to x.
Thanks for all the answers!
string.replace("rn","n")
works but is not a good solution
Tried debugging frontend and backend. Thats why we lnow, that the Problem is on the line breaks.
Expected: all strings have the same line ending, so that there are no unexpected values.
mamp is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.