{"id":294,"date":"2022-05-17T12:00:00","date_gmt":"2022-05-17T12:00:00","guid":{"rendered":"https:\/\/staging.infragistics.com\/blogs\/?p=294"},"modified":"2025-02-18T12:40:12","modified_gmt":"2025-02-18T12:40:12","slug":"blazor-vs-razor","status":"publish","type":"post","link":"https:\/\/www.infragistics.com\/blogs\/blazor-vs-razor","title":{"rendered":"Blazor vs Razor: The Difference Solved"},"content":{"rendered":"\n<p>With the release of .NET 6, and the hype-cycle around Blazor as a go-to solution for C# developers to write single-page web applications, the question comes up, \u201cWhat is the difference between Blazor and Razor\u201d?<\/p>\n\n\n\n<p>Though Blazor and Razor are not directly comparable, as they represent two distinct capabilities, often the terms for Blazor components and Razor components are widely used interchangeably.<\/p>\n\n\n\n<p>With this article, I will clear up the difference between Blazor vs Razor, as well as show you how to use each in Ignite UI for Blazor.&nbsp; You\u2019ll also build a .NET 6 app, using the Card View component from Ignite UI, so you can get familiar with Blazor and Razor in a real application!<\/p>\n\n\n\n<p class=\"text--align-center\"><a class=\"trackBlogCTA ui-btn ui-btn--default ui-btn--sm\" title=\"Button \/ Ignite UI for Blazor \/ Try It Now\" href=\"\/products\/ignite-ui-blazor\/download\">Try Ignite UI for Blazor<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-blazor\">What Is Blazor<\/h2>\n\n\n\n<p>Blazor is a free open-source web framework, enabling developers to create interactive web UIs with C#,&nbsp;HTML code&nbsp;and Razor syntax instead of JavaScript. The way Blazor works is that it creates client-based apps with WebAssembly and Server-side applications with ASP.NET. The Server app communicates with the browser through a constant connection using SignalR, while WebAssembly executes directly in the browser.<\/p>\n\n\n\n<p>Our blog features a detailed overview of Blazor, Blazor WebAssembly, and Blazor Server. So in case you want to dive in deeper, go on and read <a href=\"\/blogs\/blazor-server-vs-blazor-webassembly\/\">Blazor Server vs. Blazor WebAssembly<\/a> blog post.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-razor\">What Is Razor<\/h2>\n\n\n\n<p>While Blazor is a framework, Razor, or Razor Pages, is a templating (View) engine. The Razor syntax combines Razor markup, C#, and HTML to create dynamic web content. Typically, Razor is used for powering ASP.NET MVC Views. So, every time you write an MVC View, you will usually use Razor syntax to bind data to the markup. In an MVC app, the Razor page is processed on the server, and then sent to the client as a single HTML page.&nbsp; When the page is refreshed in the browser, it is re-processed on the server, and sent back to the client.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"razor-vs-blazor-difference\">Razor vs Blazor: The Difference &amp; the Link Between Them Solved<\/h2>\n\n\n\n<p>Blazor is a framework that leverages the Razor components to produce dynamic HTML. The biggest difference between Razor and Blazor is that Razor is a markup language with C#, while Blazor is the framework that lets you run C# code and use the Razor view engine in the browser.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"blazor-vs-razor-components\">And What About Blazor vs Razor Components?<\/h2>\n\n\n\n<p>Razor components are units of markup and code that represent the basic UI elements of any Blazor app implemented with a .razor&nbsp;extension. In other words, Blazor&nbsp;uses&nbsp;Razor&nbsp;components to create UIs, meaning you can write Razor components and utilize Blazor as the client-side hosting model for them.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"using-blazor-and-razor-in-ignite-ui\">This Is How to Use Blazor and Razor in Ignite UI<\/h2>\n\n\n\n<p>To get started, you must install both NodeJS and Visual Studio Code on your machine.<\/p>\n\n\n\n<p><strong>Step 1 &#8211; Create a New Blazor project<\/strong><\/p>\n\n\n\n<p>Start Visual Studio 2022 and click&nbsp;Create a new project&nbsp;on the start page, select the&nbsp;Blazor Web Assembly App&nbsp;template, and click&nbsp;Next. After providing a project name and description, click&nbsp;Create.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"http:\/\/static.infragistics.com\/marketing\/Blogs\/Migration\/00\/00\/00\/03\/12\/2677.Blazor-WASM-App-Create.jpg\" alt=\"Create a Blazor WebAssembly App in Visual Studio 2022\" title=\"Create a Blazor WebAssembly App in Visual Studio 2022\"\/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Step 2 &#8211; Install Ignite UI for Blazor package<\/strong><\/p>\n\n\n\n<p>Right clicking the Solution, or Project, and select&nbsp;Manage NuGet Packages for Solution. Then, open the&nbsp;Browse&nbsp;tab in the package manager dialog, select the&nbsp;Infragistics&nbsp;package source, and install the&nbsp;<span style=\"font-family: 'courier new', courier;\">IgniteUI.Blazor<\/span>&nbsp;NuGet package.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"http:\/\/static.infragistics.com\/marketing\/Blogs\/Migration\/00\/00\/00\/03\/12\/2677.Add-Infragistics-Blazor-Nuget-Packages.jpg\" alt=\"Add Blazor Nuget Packages to Visual Studio Project\" title=\"Add Blazor Nuget Packages to Visual Studio Project\"\/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Step 3 &#8211; Register Ignite UI for Blazor component<\/strong><\/p>\n\n\n\n<p>Open the <span style=\"font-family: inherit;\"><strong>Program.cs<\/strong><\/span> file and register the Ignite UI for Blazor Service by adding the following after the<span style=\"font-family: 'courier new', courier;\"> builder.Services.AddScoped<\/span> \u2026 line:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">builder.Services.AddIgniteUIBlazor();<\/pre>\n\n\n\n<p><strong>&nbsp;<\/strong><\/p>\n\n\n\n<p><strong>Step 4 \u2013 Update the Imports.razor file<\/strong><\/p>\n\n\n\n<p>Add the&nbsp;<strong>IgniteUI.Blazor.Controls<\/strong>&nbsp;namespace in the&nbsp;<strong>_Imports.razor<\/strong>&nbsp;file:<\/p>\n\n\n\n<p><strong>&nbsp;<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">@using IgniteUI.Blazor.Controls<\/pre>\n\n\n\n<p><strong>Step 5 \u2013 Update the Pages\/_Layout.cshtml file<\/strong><\/p>\n\n\n\n<p>Add the Style Sheet in the&nbsp;<span style=\"font-family: 'courier new', courier;\">&lt;head&gt;<\/span>&nbsp;element of the <strong>\\wwwroot\\index.html<\/strong> file:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;head>\n\t...\n\t&lt;link href=\"_content\/IgniteUI.Blazor\/themes\/light\/bootstrap.css\" rel=\"stylesheet\" \/>\n&lt;\/head><\/pre>\n\n\n\n<p>&nbsp;<\/p>\n\n\n\n<p><strong>Step 6 &#8211; Add Ignite UI for Blazor Component<\/strong><\/p>\n\n\n\n<p>Add an Ignite UI for Blazor component to your razor page:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;IgbCard style=\"width:350px\">\n\t&lt;IgbCardMedia>\n\t\t&lt;img src=\"https:\/\/images.unsplash.com\/photo-1541516160071-4bb0c5af65ba?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=350&amp;q=80\" \/>\n\t&lt;\/IgbCardMedia>\n\t&lt;IgbCardHeader>\n\t\t&lt;h4>Jane Doe&lt;\/h4>\n\t\t&lt;h6>Professional Photographer&lt;\/h6>\n\t&lt;\/IgbCardHeader>\n\t&lt;IgbCardContent>Hi! I'm Jane, photographer and filmmaker.\n\t\tPhotography is a way of feeling, of touching,\n\t\tof loving. What you have caught on film is captured forever...\n\t\tit remembers little things, long after you have\n\t\tforgotten everything.&lt;\/IgbCardContent>\n\t&lt;IgbCardActions>\n\t\t&lt;IgbButton>More Info&lt;\/IgbButton>\n\t&lt;\/IgbCardActions>\n&lt;\/IgbCard><\/pre>\n\n\n\n<p><code><br>\n<\/code><\/p>\n\n\n\n<p><strong>Step 7 \u2013 Build &amp; Run your App<\/strong><\/p>\n\n\n\n<p>And you\u2019re all set! Click the Run button to build and run your new Blazor app running the Card View in Ignite UI!<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"http:\/\/static.infragistics.com\/marketing\/Blogs\/Migration\/00\/00\/00\/03\/12\/4743.blazor-card-view.jpg\" alt=\"Blazor Card View\" title=\"Blazor Card View\"\/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"build-enterprise-blazor-apps-with-app-builder\">Building Enterprise Blazor Apps with App Builder<\/h2>\n\n\n\n<p>Now, if you want to significantly shorten development time, you can use low-code app makers like App Builder<sup>\u0442\u043c<\/sup>.<\/p>\n\n\n\n<p><a href=\"https:\/\/www.appbuilder.dev\/platform\" rel=\"noopener\">App Builder<sup>\u0442\u043c<\/sup><\/a> is a brand-new cloud-based WYSIWYG low-code development platform and drag-and-drop app builder that streamlines everything from design to code. The main purpose of the software is to eliminate the complexity behind UI design and app creation, while still enabling you and the entire dev team to focus on domain expertise for the business logic. You can build your business app in Blazor (and Angular) much faster than before with no hand-coding. And what\u2019s more, you have the option to download your project as a zip file or publish it on GitHub.<\/p>\n\n\n\n<p>[View:https:\/\/youtu.be\/WSQ38lLacH4:578:348]<\/p>\n\n\n\n<p>Compared to other low-code tools on the market, the main differentiator is that App Builder<sup>\u0442\u043c<\/sup> is backed up by a <a href=\"https:\/\/www.appbuilder.dev\/blog\/digital-product-design-platforms\" rel=\"noopener\">Design System<\/a>, real UI components, and over 60+ UI controls. One of the best things about it is that App Builder generates production ready code in Blazor (and Angular) in a click, letting you inspect the code and easily preview how your Blazor app (or Angular app) looks and feel. And if you think about all the full-featured components you need to build modern-day business apps \u2013 like data grids, charts, Swagger UI, UI controls, customization options, theming, branding, and more \u2013 this is what the WYSIWYG drag-and-drop App Builder<sup>\u0442\u043c<\/sup> software delivers as well.<\/p>\n\n\n\n<p>Just recently, we published a comprehensive tutorial to help you build Blazor apps with App Builder and generate your Blazor code in less than 10 minutes. So, you can jump right to this <a href=\"https:\/\/www.appbuilder.dev\/blog\/blazor-code-generation\" rel=\"noopener\">Blazor&nbsp;step-by-step guide<\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"\/products\/ignite-ui-blazor\/download\"><img decoding=\"async\" src=\"https:\/\/static.infragistics.com\/marketing\/Blog-in-content-ads\/Ignite-UI-Blazor\/ignite-ui-blazor-you-get-ad.gif\" alt=\"Ignite UI Blazor\"\/><\/a><\/figure>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Terms for Blazor components and Razor components are widely used interchangeably. But Blazor and Razor are two different things. Learn all about Razor vs Blazor and see how to use each in Ignite UI.<\/p>\n","protected":false},"author":81,"featured_media":1034,"comment_status":"publish","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-294","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blazor"],"_links":{"self":[{"href":"https:\/\/www.infragistics.com\/blogs\/wp-json\/wp\/v2\/posts\/294","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.infragistics.com\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.infragistics.com\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.infragistics.com\/blogs\/wp-json\/wp\/v2\/users\/81"}],"replies":[{"embeddable":true,"href":"https:\/\/www.infragistics.com\/blogs\/wp-json\/wp\/v2\/comments?post=294"}],"version-history":[{"count":7,"href":"https:\/\/www.infragistics.com\/blogs\/wp-json\/wp\/v2\/posts\/294\/revisions"}],"predecessor-version":[{"id":1856,"href":"https:\/\/www.infragistics.com\/blogs\/wp-json\/wp\/v2\/posts\/294\/revisions\/1856"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.infragistics.com\/blogs\/wp-json\/wp\/v2\/media\/1034"}],"wp:attachment":[{"href":"https:\/\/www.infragistics.com\/blogs\/wp-json\/wp\/v2\/media?parent=294"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.infragistics.com\/blogs\/wp-json\/wp\/v2\/categories?post=294"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.infragistics.com\/blogs\/wp-json\/wp\/v2\/tags?post=294"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}