ASP.net HTMLDecode 不适用于资源条目
我有一个 ASP.net MVC 项目,它在整个项目中使用资源条目 (.resx)。
很少有资源提供 HTML,其中
example: Hello <b>World!</b>
包含段落 href 等。由于资源存储在 XML 中,因此条目是 HTMLEncoded 的
,即上面的示例如下所示。
eg: Hello <b>World!</b>
因此,无论在哪里显示资源,都不会呈现 HTML 格式,而是将 HTML 显示为可见文本。
我尝试使用 HttpUtility.HTMLDecode 和 Server.HTMLDecode,但两者都不起作用。
怎么了?还有其他解决资源问题的方法吗?
I have a ASP.net MVC project, which utilizes resource entries (.resx) through out the project.
Few the resources fed, have HTML in it
example: Hello <b>World!</b>
With paragraphs href and more. As the resources are stored in an XML, the entries are HTMLEncoded
i.e the above example looks like this
eg: Hello <b>World!</b>
Due to this, wherever the resources are displayed, the HTML formatting does not render, and instead the HTML is displayed as visible text.
I tried to use HttpUtility.HTMLDecode and Server.HTMLDecode, but both wont work.
What is wrong? Any other work around resources?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下两种方法对我来说都很好:
浏览器以粗体显示诸如
Text
之类的资源条目。某些控件对其输入进行自动 HTML 编码。这可能就是你身上发生的事情吗?
Both of the following work fine for me:
A Resource entry such as
<b>Text</b>
is displayed in bold by the browser.Some Controls do automatic HTML encoding of their inputs. Could that be what's happening for you?