Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.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
C#HtmlDecode不解码空格_C#_Asp.net - Fatal编程技术网

C#HtmlDecode不解码空格

C#HtmlDecode不解码空格,c#,asp.net,C#,Asp.net,我在ASP.NET web应用程序中有一个字符串,导致引发异常,因为代码需要一个常规字符串,但它是HTML编码的,如下所示: This is a string var names = WebUtility.HtmlDecode(this.titles).Split(','); 我理解 对应于单个空格。为了解决这个问题,我尝试使用WebUtility.HtmlDecode方法。但是,输出的字符串是相同的,因此代码仍然失败。这条线看起来像这样

我在ASP.NET web应用程序中有一个字符串,导致引发异常,因为代码需要一个常规字符串,但它是HTML编码的,如下所示:

This is a string
var names = WebUtility.HtmlDecode(this.titles).Split(',');
我理解 对应于单个空格。为了解决这个问题,我尝试使用
WebUtility.HtmlDecode
方法。但是,输出的字符串是相同的,因此代码仍然失败。这条线看起来像这样:

This is a string
var names = WebUtility.HtmlDecode(this.titles).Split(',');

我使用这种方法的方式有问题吗?从我在文档中收集的信息来看,这应该是正确的。

问题已解决。代码中的其他地方有一个bug,AntiXssEncoder正在对字符串进行重新编码。因此,每次运行时,它都会在保存字符串之前重新编码,
&
字符被转换为
&


我只是在重新编码步骤中添加了一个
WebUtility.HtmlDecode()
,问题得到了解决。代码中的其他地方有一个bug,AntiXssEncoder正在对字符串进行重新编码。因此,每次运行时,它都会在保存字符串之前重新编码,
&
字符被转换为
&


我只是在重新编码步骤中添加了一个
WebUtility.HtmlDecode()
,它已被修复。

不可复制。我无法在.NET旧版或.NET Core中复制它
System.Net.WebUtility.HtmlDecode(“Hi ;there”)
返回
Hi there
。您确定这是实际输入吗?也许字符串是双重编码的?或者包含不可见字符?不可复制我无法在.NET旧版或.NET核心中复制此内容
System.Net.WebUtility.HtmlDecode(“Hi ;there”)
返回
Hi there
。您确定这是实际输入吗?也许字符串是双重编码的?还是包含不可见字符?