.Replace(Environment.NewLine, “
”) works on localhost but not when I upload my website to host

后端 未结 4 725
灰色年华
灰色年华 2021-02-12 20:14

I have no idea why is that. Here is my code and it works perfectly when I try it on localhost but when I upload my website my text has no
\'s. Why this

4条回答
  •  别那么骄傲
    2021-02-12 20:58

    As BuildStarted mentioned in the comments, the browsers might either send \r\n or \n, which will break, if you use Environment.NewLine - and I don't think asp.net will fix that up before running your code.

    I'd suggest you use a regular expression to replace linebreaks instead: "\\r?\\n" This should match both cases (I don't expect any browser to actually use '\r' only).

提交回复
热议问题