<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Chikere</title>
    <description>The latest articles on DEV Community by Chikere (@chikeredev).</description>
    <link>https://dev.to/chikeredev</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1870680%2Fd05e13cc-cf4c-4781-bfa6-9904796fc3d4.png</url>
      <title>DEV Community: Chikere</title>
      <link>https://dev.to/chikeredev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/chikeredev"/>
    <language>en</language>
    <item>
      <title>What Is The Difference Between A MVC Controller And An API Controller?</title>
      <dc:creator>Chikere</dc:creator>
      <pubDate>Sun, 13 Apr 2025 13:42:07 +0000</pubDate>
      <link>https://dev.to/chikeredev/what-is-the-difference-between-a-mvc-controller-and-an-api-controller-2lje</link>
      <guid>https://dev.to/chikeredev/what-is-the-difference-between-a-mvc-controller-and-an-api-controller-2lje</guid>
      <description>&lt;p&gt;The .NET environment is a robust development platform and gives you a consistent structure for developing software and web applications. So, it is important that you understand MVC and API controllers and all of their interactions and functions. In this article, we will go over both controllers, their roles, and their uses in software development. &lt;/p&gt;

&lt;p&gt;Alright, here we go!🚀&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is The Difference Between A MVC Controller And An API Controller
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;The main difference between a MVC controller and an API controller is in what they can be used for: a MVC controller is primarily used to return a view or web page to the user while an API controller provides data that can be used by another application.&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;Now that you have a basic understanding of the difference between both types of controllers, you might be wondering further how they work. Let us dive deeper into both their roles and implementation. &lt;/p&gt;

&lt;h2&gt;
  
  
  Role Overview
&lt;/h2&gt;

&lt;h3&gt;
  
  
  MVC Controllers
&lt;/h3&gt;

&lt;p&gt;These controllers are implemented in the Model-View-Controller (MVC) architecture, (you can read more about this design pattern &lt;a href="https://chikeredev.hashnode.dev/what-is-mvc" rel="noopener noreferrer"&gt;here&lt;/a&gt;). They handle CRUD (Create, Read, Update, Delete) actions between the user and data, generating the result as a web page or view. You use them to build dynamic web applications with user interfaces.&lt;/p&gt;

&lt;h3&gt;
  
  
  API Controllers
&lt;/h3&gt;

&lt;p&gt;You can use these controllers to provide data from endpoints within an Application Programming Interface or an API for short. They use HTTP services to manage client requests, returning the data in JSON or XML format. You will see them in RESTful service development and can be also known as a Web API. &lt;/p&gt;

&lt;h2&gt;
  
  
  Controller Implementation
&lt;/h2&gt;

&lt;p&gt;Knowing when to use which type of controller depends on the purpose and the goal of your application. If you need to display dynamic user interfaces, then choose the MVC controller. If you do not wish for the user to interact directly with internal code, then you will choose the API controller. &lt;/p&gt;

&lt;p&gt;In my blog application, I used both types of controllers. Down below, you will see the code for &lt;code&gt;PostsController&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;PostsController&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Controller&lt;/span&gt;  
&lt;span class="p"&gt;{&lt;/span&gt;  
    &lt;span class="c1"&gt;// Omitted for brevity  &lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;PostsController&lt;/code&gt; is a MVC controller that inherits from the &lt;code&gt;Controller&lt;/code&gt; class. It handles user requests and displays blog posts in an article format directly to the screen.&lt;/p&gt;

&lt;p&gt;In the next example, you will see &lt;code&gt;PostsAPIController&lt;/code&gt;, an API controller that I developed to handle requests and returns article data in JSON format. My portfolio website used this endpoint to access data about the latest blog posts.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;ApiController&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;  
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;PostsAPIController&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;ControllerBase&lt;/span&gt;  
&lt;span class="p"&gt;{&lt;/span&gt;  
    &lt;span class="c1"&gt;// Omitted for brevity  &lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;PostsAPIController&lt;/code&gt; inherits from the &lt;code&gt;ControllerBase&lt;/code&gt; class and uses the &lt;code&gt;ApiController&lt;/code&gt; attribute. Another good option to implement could be to have the &lt;code&gt;PostsAPIController&lt;/code&gt; inherit from the &lt;code&gt;APIController&lt;/code&gt; class. &lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up - The Difference Between A MVC Controller And An API Controller
&lt;/h2&gt;

&lt;p&gt;Ok, you should have gained a better understanding of both MVC and API controllers and the difference between them. And it’s important that you understand these controllers and how you can interact with them. Sometimes projects will dictate which type of controller to implement, depending on how the user will interact with the software or web application.&lt;/p&gt;

&lt;p&gt;Thanks and keep coding! ✌️😎&lt;/p&gt;

&lt;p&gt;If you enjoyed this article, please don’t hesitate to leave a comment. Also, subscribe to this blog to get email updates on when I publish new articles. &lt;/p&gt;

</description>
      <category>dotnet</category>
      <category>mvc</category>
      <category>api</category>
    </item>
    <item>
      <title>How Are Values Passed From A Form Element in .NET?</title>
      <dc:creator>Chikere</dc:creator>
      <pubDate>Sun, 06 Apr 2025 20:24:41 +0000</pubDate>
      <link>https://dev.to/chikeredev/how-are-values-passed-from-a-form-element-in-net-4oal</link>
      <guid>https://dev.to/chikeredev/how-are-values-passed-from-a-form-element-in-net-4oal</guid>
      <description>&lt;p&gt;Working with forms and the HTML elements is a common task you can expect to perform as a developer in .NET MVC. In this post, I will show you how you can use forms to successfully pass information from the frontend to the backend for processing. So without further adieu, let’s jump in! &lt;/p&gt;

&lt;h2&gt;
  
  
  What are Tag Helpers
&lt;/h2&gt;

&lt;p&gt;In .NET MVC, tag helpers enable values to pass from the HTML form element to the controller. Basically,  they help you to create and render HTML elements by the use of server-side code. This makes code more easier to understand and quicker to develop. For a robust explanation of tag helpers and how they work, you can read an article by Microsoft &lt;a href="https://learn.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/intro?view=aspnetcore-9.0" rel="noopener noreferrer"&gt;here&lt;/a&gt;. &lt;/p&gt;

&lt;h2&gt;
  
  
  How Are Values Passed From a Form Element
&lt;/h2&gt;

&lt;p&gt;To pass a value from a form element to the backend, you’ll use a form tag helper. It generates a HTML &lt;/p&gt; element with action attribute values for interaction with a MVC controller action.

&lt;p&gt;For example, in my blog application you can create a comment using a form in the &lt;strong&gt;Create.cshtml&lt;/strong&gt; file for the Comments view, which you can see below:&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;form&lt;/span&gt; &lt;span class="na"&gt;asp-controller=&lt;/span&gt;&lt;span class="s"&gt;”Comments”&lt;/span&gt; &lt;span class="na"&gt;asp-action=&lt;/span&gt;&lt;span class="s"&gt;"Create"&lt;/span&gt; &lt;span class="na"&gt;method=&lt;/span&gt;&lt;span class="s"&gt;”post”&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;  
   &lt;span class="c"&gt;&amp;lt;!-- Input and Submit elements --&amp;gt;&lt;/span&gt;  
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;The form tag helper above generates the following HTML:&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;form&lt;/span&gt; &lt;span class="na"&gt;method=&lt;/span&gt;&lt;span class="s"&gt;"post"&lt;/span&gt; &lt;span class="na"&gt;action=&lt;/span&gt;&lt;span class="s"&gt;"/Comments/Create"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;  
    &lt;span class="c"&gt;&amp;lt;!-- Input and Submit elements --&amp;gt;&lt;/span&gt;  
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;As you can see, MVC generates the &lt;strong&gt;action&lt;/strong&gt; attribute value from the form tag helper attributes &lt;strong&gt;asp-controller&lt;/strong&gt; and &lt;strong&gt;asp-action.&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;When the submit button is pressed, the form is submitted to the &lt;strong&gt;Create&lt;/strong&gt; action of the &lt;strong&gt;Comments&lt;/strong&gt; controller, where values are passed using the &lt;strong&gt;Comment&lt;/strong&gt; model as shown in the example below.&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;HttpPost&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;   
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Create&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="nf"&gt;Bind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"PostId,Body"&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt; &lt;span class="n"&gt;Comment&lt;/span&gt; &lt;span class="n"&gt;comment&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
&lt;span class="p"&gt;{&lt;/span&gt;  
 &lt;span class="c1"&gt;// Omitted for brevity  &lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;In the code you see that the &lt;strong&gt;Create&lt;/strong&gt; action has a &lt;strong&gt;HttpPost&lt;/strong&gt; attribute which signals the MVC runtime environment that we are going to write data. You can also see a &lt;strong&gt;Comment&lt;/strong&gt; parameter with a &lt;strong&gt;Bind&lt;/strong&gt; attribute is passed to the &lt;strong&gt;Create&lt;/strong&gt; action from the form. &lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;Bind&lt;/strong&gt; attribute ensures that the &lt;strong&gt;PostId&lt;/strong&gt; and &lt;strong&gt;Body&lt;/strong&gt; properties on the &lt;strong&gt;Comment&lt;/strong&gt; parameter are always passed to the &lt;strong&gt;Create&lt;/strong&gt; action. If they are missing, then an error will occur and the &lt;strong&gt;Create&lt;/strong&gt; action will not execute in creating a comment. &lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;You are now more knowledgeable of how values are passed from HTML forms in .NET. Microsoft developed a unique way to pass values in MVC, resulting in a more efficient and simple process. &lt;/p&gt;

&lt;p&gt;If you found this article helpful, don’t hesitate to leave a comment down below in the comment section. Also, subscribe to the blog to receive updates for new content uploaded to the blog.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>dotnet</category>
      <category>csharp</category>
      <category>html</category>
    </item>
    <item>
      <title>What is Razor Syntax?</title>
      <dc:creator>Chikere</dc:creator>
      <pubDate>Sun, 06 Apr 2025 20:20:16 +0000</pubDate>
      <link>https://dev.to/chikeredev/what-is-razor-syntax-4k2e</link>
      <guid>https://dev.to/chikeredev/what-is-razor-syntax-4k2e</guid>
      <description>&lt;p&gt;At first, the name razor syntax can sound off-putting, but it is not a hard concept to understand. You will find that using razor syntax in web development is another effective and efficient way to document your code. &lt;/p&gt;

&lt;h2&gt;
  
  
  What Is Razor Syntax
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Razor syntax&lt;/em&gt;&lt;/strong&gt; &lt;em&gt;is a method that you use in Visual Studio to integrate backend code such as the C# programming language directly within the HTML code used to display web pages in the web browser.&lt;/em&gt; &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;We prefix an @ symbol in the front of a line of backend code to indicate it as razor syntax. And for multiple lines of code, you will use '@{ }' where the code is inserted between the curly braces.  &lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  How Does Razor Syntax Work
&lt;/h2&gt;

&lt;p&gt;You’ll write razor syntax in a CSHTML file or razor file, which corresponds to a view file where both C# and HTML code are alongside each other. &lt;/p&gt;

&lt;p&gt;When you run a program in Visual Studio and inspect the web page, you will see the result of razor syntax as backend code manipulating the front end. You should see just HTML and no C# code because it has been transformed into corresponding HTML.    &lt;/p&gt;

&lt;p&gt;For example, I used razor syntax alongside HTML code to embed C# within my blog application. Below is an example from the start of an abbreviated &lt;strong&gt;Create.cshtml&lt;/strong&gt; file which handles the view for creating a new blog category.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@using CEBlog.Services  
@inject IImageService imageService  
@model IEnumerable&amp;lt;'CEBlog.Models.Blog'&amp;gt;  
@{  
    ViewData["Title"] = "Index";  
    Layout = "~/Views/Shared/_LayoutForAdmin.cshtml";  
}

&amp;lt;h1&amp;gt;Index&amp;lt;/h1&amp;gt;  
&amp;lt;p&amp;gt;  
    &amp;lt;a asp-action="Create"&amp;gt;Create New&amp;lt;/a&amp;gt;  
&amp;lt;/p&amp;gt;  
…  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first couple of lines show an @ symbol in from of C# code which introduces a namespace, a service, a model, and display variable. &lt;/p&gt;

&lt;p&gt;In the following example, you will also see a &lt;strong&gt;&lt;a class="mentioned-user" href="https://dev.to/foreach"&gt;@foreach&lt;/a&gt;&lt;/strong&gt; statement which will render to HTML code, thereby reducing duplication of code and saving time in the application for you the developer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;table class="table"&amp;gt;  
    &amp;lt;thead&amp;gt;  
        ...  
    &amp;lt;/thead&amp;gt;  
    &amp;lt;tbody&amp;gt;  
        @foreach (var blog in Model)  
        {  
            &amp;lt;tr&amp;gt;  
                &amp;lt;td&amp;gt;  
                    @Html.DisplayFor(modelItem =&amp;gt; blog.Name)  
                &amp;lt;/td&amp;gt;  
                &amp;lt;td&amp;gt;  
                    @Html.DisplayFor(modelItem =&amp;gt; blog.Description)  
                &amp;lt;/td&amp;gt;  
                &amp;lt;td&amp;gt;  
                    @Html.DisplayFor(modelItem =&amp;gt; blog.Created)  
                &amp;lt;/td&amp;gt;  
                &amp;lt;td&amp;gt;  
                    @Html.DisplayFor(modelItem =&amp;gt; blog.Updated)  
                &amp;lt;/td&amp;gt;  
                &amp;lt;td&amp;gt;  
                    &amp;lt;img class="img-fluid" width="200px" src="@imageService.DecodeImage(blog.ImageData, blog.ContentType)" /&amp;gt;  
                &amp;lt;/td&amp;gt;   
                &amp;lt;td&amp;gt;  
                    &amp;lt;a asp-action="Edit" asp-route-id="@blog.Id"&amp;gt;Edit&amp;lt;/a&amp;gt; |  
                    &amp;lt;a asp-action="Details" asp-route-id="@blog.Id"&amp;gt;Details&amp;lt;/a&amp;gt; |  
                    &amp;lt;a asp-action="Delete" asp-route-id="@blog.Id"&amp;gt;Delete&amp;lt;/a&amp;gt;  
                &amp;lt;/td&amp;gt;  
            &amp;lt;/tr&amp;gt;  
        }  
    &amp;lt;/tbody&amp;gt;  
&amp;lt;/table&amp;gt;  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Benefits of Razor Syntax
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Simplified HTML generation:&lt;/strong&gt; you can embed C# code directly into HTML, making it easier to generate dynamic content.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Easy integration of C# code:&lt;/strong&gt; the @ symbol enables the transition between HTML and C# code, allowing you to write server-side logic within a view file.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Streamlined and efficient coding experience:&lt;/strong&gt; No need to explicitly denote server blocks within the HTML code&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Tip:&lt;/strong&gt; To comment code using razor syntax,  use @* *@. The comment is inserted between the asterisks. Comments in this format will not be visible in the rendered output.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Conclusion - Razor Syntax
&lt;/h2&gt;

&lt;p&gt;There you go! We went over razor syntax, how it works, and its benefits. You should now be able to confidently implement razor syntax in the views of your projects to speed up your workflow and be more efficient.&lt;/p&gt;

&lt;p&gt;If you like this content, please don’t hesitate to leave a comment in the comment section below. Also, feel free to subscribe to this blog so that you can get updates to this blog whenever new content is added. &lt;/p&gt;

</description>
      <category>dotnet</category>
      <category>programming</category>
      <category>csharp</category>
      <category>mvc</category>
    </item>
    <item>
      <title>What is MVC Routing in .NET?</title>
      <dc:creator>Chikere</dc:creator>
      <pubDate>Sun, 06 Apr 2025 20:14:08 +0000</pubDate>
      <link>https://dev.to/chikeredev/what-is-mvc-routing-in-net-4839</link>
      <guid>https://dev.to/chikeredev/what-is-mvc-routing-in-net-4839</guid>
      <description>&lt;p&gt;It might seem like magic, but there is a method in .NET to how you are able to view web pages in the web browser. In this blog post, I will go over MVC routing, how it works, and why it is important. Now, let’s dive right in!&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is MVC Routing
&lt;/h2&gt;

&lt;p&gt;MVC stands for Model-View-Controller and is a programming design pattern implemented in .NET MVC. If you’re unfamiliar with this pattern, then go ahead and read an explanation about it in my earlier post &lt;a href="https://hashnode.com/post/cm90uaefk001f09jn2soq7bhk" rel="noopener noreferrer"&gt;here&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;MVC routing&lt;/em&gt;&lt;/strong&gt; &lt;em&gt;is the method to how we navigate to pages in .NET MVC web applications. When the user submits a URL into the address bar of the web browser, the URL is mapped to the controller action, which returns the correct web page into the browser.&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;The default MVC routing pattern is &lt;strong&gt;Controller/Action/Id&lt;/strong&gt; and is included as part of the source URL. The pattern maps the first segment to the controller, the second segment into the controller action, and then the third segment to the id parameter, which identifies the specific data or model. &lt;/p&gt;

&lt;h2&gt;
  
  
  How Does MVC Routing Work
&lt;/h2&gt;

&lt;p&gt;Suppose you entered the following URL into the address bar of the web browser:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxclwfla6cl6jkegxeqp7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxclwfla6cl6jkegxeqp7.png" alt="browser-example" width="457" height="82"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;MVC routing would then map this URL into the pattern, https://localhost:1234/{controller}/{action}/{id} where the parameters are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Controller = Home.&lt;/strong&gt; The Home controller would handle the request.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Action = Details.&lt;/strong&gt; The Details action or method of the the Home controller  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Id = 3.&lt;/strong&gt; This parameter is optional and is used to query the data for the specific model.  &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, in my blog application, the Blogs Details page displays the information for a blog. In order to display the blog information onto the web page, you will enter the request URL into the address bar of the web browser: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnbc9fyhwtk4ussey3j17.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnbc9fyhwtk4ussey3j17.png" alt="browser-example-2" width="447" height="83"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The routing of &lt;strong&gt;Blogs/Details/5&lt;/strong&gt; would work by having the &lt;strong&gt;Details&lt;/strong&gt; action of the &lt;strong&gt;Blogs&lt;/strong&gt; controller query the database for the blog with &lt;strong&gt;Id&lt;/strong&gt; of 5. If found, the blog is returned as a Model to the View where the information is displayed in the browser as a web page.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Questions -  MVC Routing
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What happens if we don’t enter one or some of the parameters?&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;If you don’t enter a controller name, it defaults to the value of &lt;strong&gt;Home&lt;/strong&gt;. If you don’t enter an action, it defaults to the value of &lt;strong&gt;Index&lt;/strong&gt;. If you don’t enter an id, it defaults to an empty string.  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do we make changes to the MVC routing in .NET?&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;To make changes, you must edit the endpoint routing in the &lt;strong&gt;Program.cs&lt;/strong&gt; file that comes with every MVC project file. In the following example you see the code of the default MVC routing for a sample .NET MVC project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;UseEndpoints&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;endpoints&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt;  
&lt;span class="p"&gt;{&lt;/span&gt;    
    &lt;span class="n"&gt;endpoints&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;MapControllerRoute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;  
        &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"default"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  
        &lt;span class="n"&gt;pattern&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"{controller=Home}/{action=Index}/{id?}"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="p"&gt;});&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion - MVC Routing
&lt;/h2&gt;

&lt;p&gt;So, that’s MVC routing explained in a nutshell. Basically, to request a web page in .NET, you must use parameters along with the source URL to map to the correct view. &lt;/p&gt;

&lt;p&gt;I hope you enjoyed learning about MVC routing. If you found this article to be helpful, don’t forget to leave a comment below and subscribe to receive future updates on any new articles.&lt;/p&gt;

</description>
      <category>mvc</category>
      <category>programming</category>
      <category>dotnet</category>
    </item>
    <item>
      <title>How To Solve Fizz Buzz With JavaScript</title>
      <dc:creator>Chikere</dc:creator>
      <pubDate>Sun, 06 Apr 2025 20:07:25 +0000</pubDate>
      <link>https://dev.to/chikeredev/how-to-solve-fizz-buzz-with-javascript-3gk2</link>
      <guid>https://dev.to/chikeredev/how-to-solve-fizz-buzz-with-javascript-3gk2</guid>
      <description>&lt;h3&gt;
  
  
  In this article
&lt;/h3&gt;

&lt;p&gt;What is Fizz Buzz&lt;br&gt;&lt;br&gt;
How to Solve Fizz Buzz&lt;br&gt;&lt;br&gt;
Tips for Solving Fizz Buzz&lt;br&gt;&lt;br&gt;
Wrapping Up&lt;/p&gt;

&lt;p&gt;Are you learning to code or preparing for an upcoming coding interview? In this post, we’ll explain the Fizz Buzz problem and then take you through the process of solving this exercise. At the end, you should be confident enough in solving this exercise and other similar coding problems. If that sounds good to you, then let’s go!&lt;/p&gt;

&lt;p&gt;&lt;a id="what-is-fizz-buzz"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  What is Fizz Buzz?
&lt;/h2&gt;

&lt;p&gt;Fizz Buzz is a coding exercise where you’ll output the numbers from 1 to 100 with multiples of three displayed as "Fizz", multiples of five as "Buzz", and then multiples of both three and five as "FizzBuzz".&lt;/p&gt;

&lt;p&gt;This coding problem has been given during coding interviews to candidates who want to be selected for a software developer role. Knowing how to solve this type of challenge can bring you one step closer to gaining that position. &lt;/p&gt;

&lt;p&gt;&lt;a id="how-to-solve-fizz-buzz"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  How to Solve Fizz Buzz
&lt;/h2&gt;

&lt;p&gt;To solve this challenge in the simplest way possible, use HTML and CSS to create the user interface on a static web page. And then you’ll code in JavaScript to handle the user interaction and to display the final results.&lt;/p&gt;

&lt;p&gt;Now, break the execution down into three JavaScript functions: a controller function, a helper function, and a view function. This will keep your program organized, manageable, and easily understood.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 1 - Implement Controller Function
&lt;/h2&gt;

&lt;p&gt;Use the controller function as the main function, which is responsible for the overall flow of execution of the program. The controller function will call the other functions to process the numbers and complete the results.&lt;/p&gt;

&lt;p&gt;The following code shows the controller function named &lt;code&gt;getValues&lt;/code&gt;. It receives the user input, parses the fizz and the buzz values as numbers, and then calls both the helper and view functions for processing.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getValues&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;//get values from the page&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;fizzValue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;fizzValue&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;buzzValue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;buzzValue&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;//Need to validate input&lt;/span&gt;
    &lt;span class="c1"&gt;//parse into integers&lt;/span&gt;
    &lt;span class="nx"&gt;fizzValue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;parseInt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fizzValue&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;buzzValue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;parseInt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;buzzValue&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isInteger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fizzValue&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isInteger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;buzzValue&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;//call generateNumbers&lt;/span&gt;
        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;numbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;generateNumbers&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

        &lt;span class="c1"&gt;//call displayNumbers&lt;/span&gt;
        &lt;span class="nf"&gt;displayNumbers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fizzValue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;buzzValue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nf"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;You must enter integers&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 2 - Create a Helper Function
&lt;/h2&gt;

&lt;p&gt;Now, use the helper function to handle one task. This function assists the controller function in breaking down code into smaller, manageable code. &lt;/p&gt;

&lt;p&gt;The following code illustrates the helper function named &lt;code&gt;generateNumbers&lt;/code&gt;. It generates and transfers numbers 1 to 100 into an array using a for loop, and then returns the number array back to the controller function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;generateNumbers&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;numbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;

    &lt;span class="c1"&gt;//get all numbers from start to end&lt;/span&gt;

    &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;//execute in a loop until index = endValue&lt;/span&gt;
        &lt;span class="nx"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 3 - Code the View Function
&lt;/h2&gt;

&lt;p&gt;Finally, use a view function to display the results to the user. The following code shows the view function named &lt;code&gt;displayNumbers&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;displayNumbers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fValue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;bValue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;templateRows&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

        &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;templateRows&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s2"&gt;``&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;number&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="nx"&gt;fValue&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="nx"&gt;bValue&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;className&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;fizzBuzz&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="nx"&gt;templateRows&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;number&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="nx"&gt;fValue&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;className&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;fizz&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="nx"&gt;templateRows&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;number&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="nx"&gt;bValue&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
            &lt;span class="nx"&gt;className&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;buzz&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="nx"&gt;templateRows&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;templateRows&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;templateRows&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s2"&gt;``&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;results&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;templateRows&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;First, the controller function passes the fizz value, the buzz value, and the numbers array into the function. The values are processed using a for loop and if-then-else conditional statements. They are then templated onto the page using different colors to maximize user readability.&lt;/p&gt;

&lt;p&gt;&lt;a id="tips"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Tips for Solving Fizz Buzz
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Use a language that you are comfortable in programming. The examples shown were coded in JavaScript, however you could’ve used another language such as C# or Python.
&lt;/li&gt;
&lt;li&gt;Learn about arrays, the uses for an array, and all of the functions for arrays.
&lt;/li&gt;
&lt;li&gt;Be comfortable with creating for-loops, including while and do-while loops.
&lt;/li&gt;
&lt;li&gt;Know about conditional statements, such as if and if-else, and when to use them.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a id="wrapping-up"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping Up - How To Solve Fizz Buzz
&lt;/h2&gt;

&lt;p&gt;There you go! You’ve learned about the Fizz Buzz exercise and the process for solving it, using a controller function, a helper function, and a view function. Although I’ve only shown you one way, there are other ways in solving this problem. You should be ready now to practice by coding some more on your own.  &lt;/p&gt;

&lt;p&gt;I’ve also coded my own solution for Fizz Buzz and deployed it using Netlify. You are welcome to demo it &lt;a href="https://c-fizzbuzz.netlify.app/" rel="noopener noreferrer"&gt;here&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;If you found this post helpful, don’t forget to leave a comment below. Also, subscribe to sign-up for future email updates when new articles are published to this blog.   &lt;/p&gt;

</description>
      <category>programming</category>
      <category>javascript</category>
      <category>challenge</category>
    </item>
    <item>
      <title>What is MVC?</title>
      <dc:creator>Chikere</dc:creator>
      <pubDate>Sun, 06 Apr 2025 20:03:24 +0000</pubDate>
      <link>https://dev.to/chikeredev/what-is-mvc-58f0</link>
      <guid>https://dev.to/chikeredev/what-is-mvc-58f0</guid>
      <description>&lt;p&gt;MVC is a software programming design pattern and stands for model, view, controller. It is used to achieve a separation of concerns, which makes it easier to organize and program complex applications.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Controller&lt;/strong&gt;: It listens for requests from the user and then takes those requests to interact with both the models and the views.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Model&lt;/strong&gt;: It is the data or information from the database that is being requested in order to display to the user.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;View&lt;/strong&gt;: This is the graphic user interface (gui) or web pages that display information on the screen to the user.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, in my contact book application, the Contact Edit page displays to the user the information for a single contact on a page in the web browser. The &lt;strong&gt;Edit&lt;/strong&gt; action will have the Contacts &lt;strong&gt;Controller&lt;/strong&gt; query the database for the contact using the contact id number. If the id number is found, the contact is returned as a &lt;strong&gt;Model&lt;/strong&gt; to the &lt;strong&gt;View&lt;/strong&gt; where information is displayed on the web page.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ContactsController&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Controller&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// GET: Contacts/Edit/5&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;Authorize&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="n"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;IActionResult&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;Edit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="p"&gt;==&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt; &lt;span class="p"&gt;||&lt;/span&gt; &lt;span class="n"&gt;_context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Contacts&lt;/span&gt; &lt;span class="p"&gt;==&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;NotFound&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;appUserId&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;_userManager&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetUserId&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;User&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;contact&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;_context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Contacts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Id&lt;/span&gt; &lt;span class="p"&gt;==&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AppUserID&lt;/span&gt; &lt;span class="p"&gt;==&lt;/span&gt; &lt;span class="n"&gt;appUserId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                             &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FirstOrDefaultAsync&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;contact&lt;/span&gt; &lt;span class="p"&gt;==&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;NotFound&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;View&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;contact&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, learning about MVC is simple to understand and easy to implement. Don’t forget to leave a comment below to add to the conversation.&lt;/p&gt;

</description>
      <category>dotnet</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
