0

我在 msdn 中看到了MvcHtmlString,但我有一个关于编码的问题。

编码和解码值到底是什么Encode ASP.Net MVC以及有什么区别?

4

1 回答 1

2

Some characters must be encoded to ensure proper display. For instance < and > are special characters that tell the browser that the text between the two is an HTML tag and must be interpreted as part of the markup. To be able to display < and > as part of the text, it must be encoded. HTML encoding will substitute these with &lt and &gt respectively. The browser then knows it's not part of the markup and displays it accordingly.

Decoding is the other way around: &lt becomes <, &amp becomes &, etc.

于 2012-09-14T10:08:09.790 回答