Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net HtmlEncode不是';正确编码_Vb.net_Html Encode - Fatal编程技术网

Vb.net HtmlEncode不是';正确编码

Vb.net HtmlEncode不是';正确编码,vb.net,html-encode,Vb.net,Html Encode,似乎没有对字符串进行编码 问题: Dim encodedStr As String = HttpUtility.HtmlEncode("<p>This is a test</p>") 我会仔细检查以确保显示值的内容确实是以文本模式显示的,而不是HTML。在调试器下,它可以正常工作: HttpUtility.HtmlEncode("<p>This is a test</p>"); "&lt;p&gt;This is a test&a

似乎没有对字符串进行编码

问题:

Dim encodedStr As String = HttpUtility.HtmlEncode("<p>This is a test</p>")

我会仔细检查以确保显示值的内容确实是以文本模式显示的,而不是HTML。在调试器下,它可以正常工作:

HttpUtility.HtmlEncode("<p>This is a test</p>");
"&lt;p&gt;This is a test&lt;/p&gt;"
HttpUtility.HtmlEncode(这是一个测试

”; “p这是一个测试/p”

(是的,这是C#但是.NET framework代码都是共享的,我很懒)

在调试器下运行时对我有效。您如何看待输出?您确定没有在HTML模式下查看值吗?很好。那应该是我的第一个预感。。我将一个编码字符串传递给一个电子邮件应用程序,我想我假设电子邮件是以textAh的形式发送的,这是有道理的。我已经添加了我的官方答案,这样你就可以得到你的2分:)
&lt;p&gt;This is a test&lt;/p&gt;
HttpUtility.HtmlEncode("<p>This is a test</p>");
"&lt;p&gt;This is a test&lt;/p&gt;"