C# 如何正确使用HTML解码?

C# 如何正确使用HTML解码?,c#,html,asp.net,tinymce,C#,Html,Asp.net,Tinymce,我在数据库中存储了一些文本: &amp;lt;p&amp;gt;Hi this is Roht &amp;lt;strong&amp;gt;Singh&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt; 当我检索它并用HTML将其解码为label控件时,它会给出以下文本: <p>Hi this is Roht <strong>Singh</strong></p

我在数据库中存储了一些文本:

&amp;lt;p&amp;gt;Hi this is Roht &amp;lt;strong&amp;gt;Singh&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;
当我检索它并用HTML将其解码为label控件时,它会给出以下文本:

<p>Hi this is Roht <strong>Singh</strong></p>
如何将文本呈现为HTML格式

你好,我是罗特·辛格


看起来您的数据被HTML编码了两次。尝试解码两次:

label1.Text = Server.HtmlDecode(
                    Server.HtmlDecode(ds.Tables[0].Rows[0][0].ToString()
              );
获取原始数据时:

&amp;lt;p&amp;gt;Hi this is Roht &amp;lt;strong&amp;gt;Singh&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;
如果使用HTML对其进行解码,则会得到以下结果:

&lt;p&gt;Hi this is Roht &lt;strong&gt;Singh&lt;/strong&gt;&lt;/p&gt;
当您对该结果进行HTML解码时,您会得到:

<p>Hi this is Roht <strong>Singh</strong></p>
你好,我是罗特·辛格

然后应将其呈现为:

你好,我是罗特·辛格


看起来您的数据被HTML编码了两次。尝试解码两次:

label1.Text = Server.HtmlDecode(
                    Server.HtmlDecode(ds.Tables[0].Rows[0][0].ToString()
              );
获取原始数据时:

&amp;lt;p&amp;gt;Hi this is Roht &amp;lt;strong&amp;gt;Singh&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;
如果使用HTML对其进行解码,则会得到以下结果:

&lt;p&gt;Hi this is Roht &lt;strong&gt;Singh&lt;/strong&gt;&lt;/p&gt;
当您对该结果进行HTML解码时,您会得到:

<p>Hi this is Roht <strong>Singh</strong></p>
你好,我是罗特·辛格

然后应将其呈现为:

你好,我是罗特·辛格


我已经解决了它,我有HTMLDE代码再次文本,它是工作。
Ans:Server.HtmlDecode(Server.HtmlDecode(ds.Tables[0].Rows[0][0].ToString())

我已经解决了这个问题,我再次对文本进行了HTMLDE编码,它开始工作了。
Ans:Server.HtmlDecode(Server.HtmlDecode(ds.Tables[0].Rows[0][0].ToString())

我也使用了文字,但仍然和我的编辑一样。看起来数据库数据是双重编码的。我也使用了literal,但我的编辑还是一样的。看起来数据库数据是双重编码的。