Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
使用 ActionLink 从具有 HTML 标签的数据库中呈现数据时
(ie <p>)
并入其中,ActionLink 会转义标签。处理这个问题的最佳方法是什么?
我不知道您可以在辅助方法中关闭 XSS 保护,但您始终可以构建自己的辅助方法。只需制作一个挂起 Html 类的扩展方法。
如果您只想从数据库中呈现一些 HTML,则可以使用 <%= ViewData["MyContent"] %> 如果您是控制器将数据加载到 MyContent 视图数据中。只知道你必须自己清理这个 HTML。
在有效的 (X)HTML 中,锚标记内不允许使用段落标记,因此我不希望框架允许它。