Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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]?
like image 265
Roddy Balkan Avatar asked Dec 19 '22 04:12

Roddy Balkan


1 Answers

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

like image 171
Dmitry Avatar answered May 12 '23 07:05

Dmitry