(C# ASP.NET Core) Practice Exercises and Questions on Modularity

(LEVEL IS BEGINNERS) These are practice questions and exercises on Modularity in Razor Pages. Solve them and join our course for their solutions.

Categories | About |     |  

Parveen,
COMMERCIAL USE OF THIS CONTENT IS NOT ALLOWED

Exercises on Modularity

for solutions please join our Course on ASP.NET Core with Project ("Find a Doctor")
  1. [print name, razor components] Write a razor component that has a function called "GetName" that returns your name as a string. The razor component displays your name by calling this function. Embed this component in your index.cshtml razor page to display your name.

  2. [count chars in a string, razor components] Write a razor component that takes two parameters - HostName and CharToCount. The first parameter is the name of a website - like microsoft - without the prefix "https://" and the suffix ".com", and the second parameter is a character, such as 'A'. Your razor component will send a hit to https://{HostName}.com and download the page as a string, and count the number of {CharToCount} in that string and display the characters counted. Use this razor component in a razor page that has a form that accepts HostName and CharToCount as inputs from the user. When the user submits the form, these inputs should be passed to the razor component to display the number of characters found. Hint: use an HttpClient request in "OnInitializedAsync" to download the string and count the chars. You might want to review the tutorial L02 - Razor Components where makeSquare function has been discussed along with passing parameters.


This Blog Post/Article "(C# ASP.NET Core) Practice Exercises and Questions on Modularity" by Parveen is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Comments and Discussion