Sascha Manns
Sascha Manns's Twilight Zone

Sascha Manns's Twilight Zone

Adding a estimated time to read to a .NET Core Blog with Razor

Sascha Manns's photo
Sascha Manns
·Apr 14, 2019·

2 min read

Subscribe to my newsletter and never miss my upcoming articles

This week i implemented a feature what shows you, how many time you have to spend, to read a blog article.

In the first step, i used my model BlogStory to get the content. Then Razor does the following:

  1. It counts the spaces between the words and adds 1. So now we knowing how many words we have in that article.
  2. The most people can read 200 to 250 in one minute. So we need to divide the counted words with 250. Then we knowing, how many minutes it takes to read.
  3. Then we combine a modulo with a divide to get the seconds.
    var word_count = @Model.Body;
    var counts = word_count.Count(ch => ch == ' ') + 1;    
    var minutes = counts / 250;
    var seconds = counts % 250 / (250 / 60);
    var str_minutes = (minutes == 1) ? "Minute " : "Minutes ";
    var str_seconds = (seconds == 1) ? "Second " : "Seconds ";    

Now we placing the code for displaying the estimated time to read

<i class="fas fa-clock"></i> @minutes @str_minutes  @seconds @str_seconds

On the place, where this snipped is, will be the estimated time to read.

Currently it is placed on client side. It is planned to move that function to server side in future.

Creative Commons License

This work by Sascha Manns is licensed under a Attribution-ShareAlike 3.0 Germany License (CC BY-SA 3.0 DE).
Based on a work at

Did you find this article valuable?

Support Sascha Manns by becoming a sponsor. Any amount is appreciated!

Learn more about Hashnode Sponsors
Share this


Service provider

Sascha Manns

Contact options

E-Mail address:

Journalistic and editorial offers

Content responsibility: Sascha Manns (email address above)

Social media and other presences

This imprint also applies to the following social media presences and online profiles:

  • (
  • (
  • (
  • (
  • (
  • (
  • (
  • (
Liability and property rights notices

Disclaimer of liability: The content of this online offer was created carefully and according to our current state of knowledge, but is only for information purposes and does not have any legally binding effect, unless it is legally binding information (e.g. the imprint, the data protection declaration, terms and conditions or mandatory instructions for consumers). We reserve the right to change or delete the content in full or in part, provided that contractual obligations remain unaffected. All offers are non-binding.

Links to other websites: Contents of external websites to which we refer directly or indirectly are outside our area of responsibility and we do not adopt them as our own. The provider of the linked websites is solely liable for all content and in particular for damage resulting from the use of the information that can be accessed on the linked websites.

Copyrights and trademark rights: All content presented on this website, such as texts, photographs, graphics, brands and trademarks are protected by the respective property rights (copyrights, trademark rights). The use, reproduction, etc. are subject to our rights or the rights of the respective authors or rights administrators.

Notes on legal violations: If you notice legal violations on our website, we ask you to inform us about them. We will remove illegal content and links immediately after taking notice.

Created with free Datenschutz-Generator by Dr. Thomas Schwenke