locked
How should I load article by asp.net core? RRS feed

  • Question

  • User1052024640 posted

    I am making a website of fiction by asp.net core.

    All pages are almost the same while with different articles, so I made them base on a template.

    Now I need to load the fiction into the page. I have two ideas to achieve this.

    One is by storing it in the database. However, each fiction has a large and different letter count. It seems not well to store it in the database.

    The other is by storing it in a .Txt file, then load and cache it.  Whereas, I don't know how to set the.Txt file to private(not allow download the .Txt file by any other people).

    I am not sure which of my idea is right. Or there is a better solution. Would you please give me a suggestion? Thank you.

    Thursday, November 5, 2020 2:06 AM

Answers

  • User-821857111 posted

    One is by storing it in the database. However, each fiction has a large and different letter count. It seems not well to store it in the database.
    That's how you should do it. Use nvarchar(max) as the column data type. 

    If the article content is HTML, use @Html.Raw() to output it is Razor.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, November 5, 2020 7:22 AM

All replies

  • User1312693872 posted

    Hi,mywatermelon

    If the fiction is a plaintext,

    • You can store the fiction into a database, if it's a long fiction,You can store them in chapters.For example, fiction model can have  fictionId,

    fictionnames. And fiction model can be bound to chapters for easy management and query.

    • If it is a short story, you can save it as txt, but make sure that the format inside is correct.

    I recommend using the database method, although the design is complicated but it will be easy to manage.

    Best Regards,

    Jerry Cai

    Thursday, November 5, 2020 5:31 AM
  • User1052024640 posted

    Thanks for helping me.

    I am sorry I don't know what is the plaintext truly means.  It seems it is an HTML element that has been abandon.

    The article I need to store just like this:

    <h1>Harry Potter</h1>

    <article>Harry Potter is a series of seven fantasy novels written by British author J. K. Rowling. The novels chronicle the lives of a young wizard, Harry Potter, and his friends Hermione Granger and Ron Weasley, all of whom are students at Hogwarts School of Witchcraft and Wizardry. The main story arc concerns Harry's struggle against Lord Voldemort, a dark wizard who intends to become immortal, overthrow the wizard governing body known as the Ministry of Magic and subjugate all wizards and Muggles (non-magical people).</article>

    Thursday, November 5, 2020 6:28 AM
  • User-821857111 posted

    One is by storing it in the database. However, each fiction has a large and different letter count. It seems not well to store it in the database.
    That's how you should do it. Use nvarchar(max) as the column data type. 

    If the article content is HTML, use @Html.Raw() to output it is Razor.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, November 5, 2020 7:22 AM
  • User1052024640 posted

    Thank you so much.

    Thursday, November 5, 2020 8:57 AM