c# - 仅在 .cshtml 页面(剃刀)中呈现 html 标记(链接)
问题描述
例子:
string ChatMessage = "Check this website <a href=\"http://www.example.com\">http://www.example.com</a><script>alert(1);</script><h1>Hi</h1>";
@Html.Raw(ChatMessage)
输出
Check this website http://www.example.comHi";
我想
Check this website http://www.example.com<script>alert(1);</script><h1>Hi</h1>";
我可以使用@Html.Raw(它对 JavaScript 注入和其他 html 标签开放)。
如何使用 @Html.Raw 或其他东西仅<a href="http://www.example.com">http://www.example.com</a>
在 .cshtml 页面中呈现?
解决方案
推荐阅读
- php - WooCommerce - 自定义库存状态和可变产品
- php - 基于从选项字段中选择的选项从数据库表列中获取变量到输入字段
- android - 模拟器不断重启Android Studio 3.1.4?
- multithreading - 一个进程如何使用套接字处理 Web 服务器上的多个请求?TCP
- javascript - 如何使用节点 js 生成 cookie?
- google-cloud-platform - 谷歌云永久磁盘中的根永久磁盘和非根永久磁盘
- sql - SQL:在特定天数后更新列
- angular - 每条记录多行的角度材料表
- docker - Docker:无法从 Spring Boot 应用程序读取类路径资源
- python - 添加
列表前的标签