Dario Benevento
Dario Benevento

Reputation: 47

ASP.NET Core 2.1 load razor page from text file

I would try to load in my ASP.NET Core 2.1 web application, some little pieces of views dynamically from a text file. This will allow me to load some specialized DIVs at runtime. Is there a way to make it runs or is a wrong way? Thank you

Upvotes: 1

Views: 576

Answers (1)

ChargerIIC
ChargerIIC

Reputation: 1690

You 'can' do this by loading the text file contents into a string, then using the @Html.Raw directive to 'output' the HTML to the webpage.

However, you may want to consider if this is really the best method for achieving what you want. Text files and their loading can be both slow and rather insecure (wouldn't want someone opening the text file up in notepad and typing an offensive message for example).

Upvotes: 1

Related Questions