在Asp.Net Core 2.0中使用AllowHtml从数据库生成网页 [英] Generate web page from Database using AllowHtml in Asp.Net Core 2.0

查看:189
本文介绍了在Asp.Net Core 2.0中使用AllowHtml从数据库生成网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用Asp.Net 4.61的应用程序,在其中我从数据库字段Description中读取html,并用它来填充我的应用程序中的页面.我通过用[AllowHtml]标记属性Description来做到这一点.

I have an application use Asp.Net 4.61 in which I read html from a database field Description and use it to populate my a page in my application. I do this by marking the property Description with [AllowHtml].

在我的Asp.Net Core 2.0应用程序中,我收到一条错误,指出找不到程序集引用或指令.

In my Asp.Net Core 2.0 app, I get an error that the assembly reference or directive is not found.

我有2个问题-希望以后我能够更好地回答这样的问题:

I have 2 questions - that will hopefully enable me to better answer questions such as this in the future:

  1. 是否可以搜索文档/站点来查看AllowHtml是否为 在Core 2.0中
  2. 如果我想使用一种更好/更安全的方法,应该使用 通过从我的数据库中读取而不是用[AllowHtml]装饰字段/属性来填充网页?
  1. Is there a document/site that I could search to see if AllowHtml is in Core 2.0
  2. Is there a better/more secure way that I should use if I want to populate web pages by reading from my database than decorating the field/property with [AllowHtml]?

推荐答案

您不再需要[AllowHtml],因为没有人拒绝ASP.NET Core 2.0中的HTML:

You don't need [AllowHtml] anymore, because nobody denies HTML in ASP.NET Core 2.0:

不需要[AllowHtml]或RequestValidationEnabled,因为我们没有请求该系统中的验证

相反, 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆