如何在mvc .net中显示工作超链接

时间:2022-11-15 09:53:21

I currently have an .net Mvc web project that displays comments that are submitted by users and are stored in a database.

我目前有一个.net Mvc Web项目,它显示用户提交的注释并存储在数据库中。

I was wondering if anyone had any information on how to embed a link in the comment so that is can be clicked on and followed to the desired well link :)

我想知道是否有人有任何关于如何在评论中嵌入链接的信息,以便可以点击并按照所需的井链接:)

I am aware that I can google this however with the language in this given question finding an answer on google has been quite basic and not too accurate.

我知道我可以谷歌这个,但在这个给定的问题中找到答案谷歌已经非常基本,不太准确。

1 个解决方案

#1


1  

Well you can store the comments as html in the database then display it using Html.Raw but that opens up many security flaws. The best option is to setup some custom tag to represent a link such as [url link="example.com]click here[/url] and then using a razor helper parse that and transform it into a html link.

那么你可以将评论作为html存储在数据库中,然后使用Html.Raw显示它,但这会打开许多​​安全漏洞。最好的选择是设置一些自定义标签来表示链接,例如[url link =“example.com]点击这里[/ url]然后使用剃须刀助手解析并将其转换为html链接。

#1


1  

Well you can store the comments as html in the database then display it using Html.Raw but that opens up many security flaws. The best option is to setup some custom tag to represent a link such as [url link="example.com]click here[/url] and then using a razor helper parse that and transform it into a html link.

那么你可以将评论作为html存储在数据库中,然后使用Html.Raw显示它,但这会打开许多​​安全漏洞。最好的选择是设置一些自定义标签来表示链接,例如[url link =“example.com]点击这里[/ url]然后使用剃须刀助手解析并将其转换为html链接。