Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
417 views
in Technique[技术] by (71.8m points)

c# - Generate web page from Database using AllowHtml in Asp.Net Core 2.0

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].

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

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

  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]?
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

Don't need [AllowHtml] or RequestValidationEnabled because we don't have request validation in this system

Instead, encode the output and Prevent Cross-Site Scripting


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...