Syncfusion Blazor Template Studio

3 Jan 202416 minutes to read

Syncfusion provides the Blazor Template Studio, which allows you to create a Syncfusion Blazor application with Syncfusion components. The Syncfusion Blazor app is created with the required component Syncfusion NuGet references, namespaces, styles, and component render code. The Template Studio provides an easy-to-use project wizard that walks you through the process of creating an application with Syncfusion components.

The steps below will assist you to create your Syncfusion Blazor Application through Visual Studio 2022:

Note: The Syncfusion Blazor Extensions for Visual Studio 2019 are available on Essential Studio release “20.3.0.56” and below.

Before use the Syncfusion Blazor Project Template, check whether the Syncfusion Blazor Template Studio Extension installed or not in Visual Studio Extension Manager by clicking on the Extensions -> Manage Extensions -> Installed. If this extension not installed, please install the extension by follow the steps from the download and installation help topic.

  1. Open Visual Studio 2022.

  2. To create a Syncfusion Blazor application, use either one of the following options:

    Option 1

    Choose Extension -> Syncfusion -> Essential Studio for Blazor -> Create New Syncfusion Project… from the Visual Studio menu.

    CreateMenu

    Option 2

    Choose File -> New -> Project from the menu. This launches a new dialogue for creating a new application. Syncfusion templates for Blazor can be found by filtering the application type for Syncfusion or by entering Syncfusion as a keyword in the search option.

    CreateNewWindow

  3. Select the Syncfusion Blazor Template Studio and click Next.

    CreateNewWizard

  4. The Syncfusion Blazor Template Studio wizard will be launched to configure the Syncfusion Blazor app.

    Note: Refer to the .NET SDK support for Syncfusion Blazor Components here.

    Project type section

    Choose one of the Syncfusion Blazor application types based on the version of the .NET SDK you are using.

    .NET SDK version Supported Syncfusion Blazor Application Type
    .NET 8.0 Syncfusion Blazor Web App
    .NET 8.0, .NET 7.0, .NET 6.0 Syncfusion Blazor WebAssembly App
    .NET 7.0, .NET 6.0 Syncfusion Blazor Server App

    In the Syncfusion Blazor Web App application type, you can configure the following options:

    Interactivity type Server, WebAssembly, Auto (Server and WebAssembly)
    Interactivity location Global, Per page/component

    WebAppTemplate

    In the Syncfusion Blazor WebAssembly App application type, you can choose ASP.NET Core hosted, Progressive Web Application, or both.

    WASMTemplate

    Note: The Progressive Web Application will be enabled if .NET 6.0 version or higher is installed.

  5. Click either Next or the Controls tab. The Syncfusion Blazor components you can add to the application are listed.

    Controls Section

    Choose the required control(s) by clicking Add.

    To unselect the added control(s), use either one of the following options:

    Option 1: Click Remove in the corresponding control box.

    Option 2: Click Delete in the control list from Project Details.

    Note: Choose at least one control to enable the Features and Configuration tab.

  6. Click either Next or the Features tab, and you will see the features listed for the selected controls. You can choose the required features.

  7. Click Next or the Configuration tab to load the Configuration section. You can choose the required (.NET 8.0, .NET 7.0, and .NET 6.0), themes, https configuration, localization option, authentication type, Blazor Web App, and Blazor Web Assembly application types.

    Depending on your Syncfusion Blazor Application Type, refer to the table below for supported authentication types.

    Syncfusion Blazor Application Type Supported Authentication Types
    Syncfusion Blazor Web App None and Individual Accounts
    Syncfusion Blazor WebAssembly App None, Individual Accounts and Microsoft Identity Platform
    Syncfusion Blazor Server App None, Individual Accounts, Microsoft Identity Platform, and Windows

    If you choose the Blazor Web App application type, you can customize the Interactivity type and Interactivity location options.

    WebAppConfiguration

    If you choose the Blazor Web Assembly App application type, you can customize the ASP.NET Core hosted and Progressive Web Application options.

    WASMConfiguration

    Project details section

    You can change the configuration details below in the Project Details section to change the application type, remove control(s) from the selected controls, or change the configurations.

    ProjectDetails

  8. Click Create button. The Syncfusion Blazor application has been created. The created Syncfusion Blazor app has the Syncfusion NuGet packages, styles, and the render code for the Syncfusion component.

    Readme

  9. If you installed the trial setup or NuGet packages from nuget.org you must register the Syncfusion license key to your application since Syncfusion introduced the licensing system from 2018 Volume 2 (v16.2.0.41) Essential Studio release. Navigate to the help topic to generate and register the Syncfusion license key to your application. Refer to this blog post for understanding the licensing changes introduced in Essential Studio.

Syncfusion integration

The Syncfusion Blazor application configures with most recent Syncfusion Blazor NuGet packages version, styles, namespaces, and component render code for Syncfusion components.

NuGet Packages

Based on the selected Syncfusion Blazor controls, the individual NuGet packages can be added as NuGet references. Refer this topic to know about the individual Blazor NuGet packages.

The latest Syncfusion Essential Studio version of a NuGet package will be added as reference entry from nuget.org if there is no internet connection. You should restore the NuGet packages when internet becomes available.

NuGetPackage

Style

The selected Syncfusion Blazor theme is added from Syncfusion NuGet and this theme reference will be added at these applications locations in Blazor.

Application type File location
Syncfusion Blazor Server App {Project location}\Pages\_Host.cshtml
Syncfusion Blazor WebAssembly App (ASPNET Core hosted)
Syncfusion Blazor WebAssembly App (ASPNET Core hosted and Progressive Web Application)
{Client Project location}\wwwroot\index.html
Syncfusion Blazor WebAssembly App
Syncfusion Blazor WebAssembly App (Progressive Web Application)
{Project location}\wwwroot\index.html

CDNLink

Namespaces

The Syncfusion.Blazor namespaces are added in the _imports.razor file.

NameSpace

Component render code

The selected Syncfusion Blazor components and features render code added as .razor files in the pages folder.

Selected control pagess added in project with selected features

Authentication Configuration

We need to register the created application in Google Platform API Console for Individual Accounts and Azure Active Directory for Microsoft Identity Platform. From Google Platform API Console registration we can get the client id for Individual Accounts. From Azure Active Directory registrations we can get the tenant id and application client id for Microsoft Identity Platform. We need to configure these id values in created applications then only application will be run correctly with authentication support.

Individual Accounts Authentication

Web Application and Progressive Web Application

  1. Go to below credentials page for the Google cloud platform API console.

    https://console.cloud.google.com/apis/credentials?project=aerobic-furnace-244104

  2. Click Create Credentials and OAuth Client Id.

    Google API console credentials page

    Google API Oauth client Id

  3. Select Application type as Web Application in client Id creation.

    ApplicationType

  4. Add your publish URL link as an Authorized URI and login URL as Redirected URI.

    RedirectedURI

  5. Click save then OAuth client id will be created and copy that credentials.

    ClientIdCreation

  6. Add that Client Id, and RedirectUri in appsettings.json file of your application.

    ClinetIdConfiguration

  7. Change the build configuration bind as google from Local in program.cs file.

    buildconfigurationbind

Microsoft Identity Platform Authentication

Server Application

  1. Go to below Azure Active Directory App Registration page.

    https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredApps

  2. Click New Registration in App Registration page.

    AppRegistration

  3. Give name of the application and selected supported type as single tenant.

    Name and supported Account type

  4. Dropdown the page, select platform as web and give your application Redirect URI and click Register.

    Platform and Redirect URI

  5. App will be registered, go to the Authentication page and tick Id token check box.

    Access token and Id token

  6. Get client tenant id and application id form overview page.

    Clinet tenat id

  7. Configure those client tenant id, application id, and domain in your application appsettings.json file.

    Project configuration

Web Application and Progressive Web Application

  1. Go to below Azure Active Directory App Registration page.

    https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredApps

  2. Click New Registration in App Registration page.

    AppRegistration

  3. Give name of the application and selected supported type as single tenant.

    Name and supported Account type

  4. Dropdown the page, select platform as web and give your application Redirect URI and click Register.

    Platform and Redirect URI

  5. App will be registered, go to the Authentication page and tick Access token an Id token check box.

    Access token and Id token

  6. Migrate the API by clicking the highlighted arrow like in below image.

    API Migration

    Migration configuration

  7. Get client tenant id and application id form overview page.

    Clinet tenat id

  8. Configure those client tenant id and application id in your application appsettings.json file.

    Clinet ID and Tenant ID configuration

ASP.NET Core Hosted Web Application, and ASP.NET Core Hosted with Progressive Web Application

Client project Registration and Configuration
  1. Go to below Azure Active Directory App Registration page.

    https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredApps

  2. Click New Registration in App Registration page.

    AppRegistration

  3. Give name of the application and selected supported type as single tenant.

    Name and supported Account type

  4. Dropdown the page, select platform as web and give your application Redirect URI and click Register.

    Platform and Redirect URI

  5. App will be registered, go to the Authentication page and tick Access token an Id token check box.

    Access token and Id token

  6. Migrate the API by clicking the highlighted arrow like in below image.

    API Migration

    Migration configuration

  7. Get client tenant id and application id form overview page.

    Clinet tenat id

  8. Configure those client tenant id and application id in your application appsettings.json file.

    Clinet ID and Tenant ID configuration

Server project Registration and configuration
  1. Go to below Azure Active Directory App Registration page.

    https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredApps

  2. Click New Registration in App Registration page.

    Server App Registration

  3. Give name of the application and selected supported type as single tenant.

    Name and supported Account type

  4. Dropdown the page, select platform as web and give your application Redirect URI and click Register.

    Server Platform and Redirect URI

  5. App will be registered, go to the Authentication page and tick Access token an Id token check box.

    Access token and Id token

  6. Migrate the API by clicking the highlighted arrow like in below image.

    API Migration

    Migration configuration

  7. Add a scope API in Expose an API page.

    Add scope API

  8. Give scope name, admin consent display name, and admin consent description and click Add scope. Scope API will be created, copy those scope API Value.

    Add scope API configuration

  9. Get client tenant id and application id form overview page.

    Clinet tenat id

  10. Configure those client tenant id, application id, and domain in your application appsettings.json file.

    Project configuration

  11. Configure the scope API in client application program.cs file below highlighted place.

    Scope API configuration

Run application

You can run the application and see the Syncfusion components you selected. Select a component to see component output.

Blazor Template output page

You can select a culture language in combobox at top right on the output page to apply the culture in the application.

Blazor Template output page

Note: Above culture combobox will be enabled in sample output if localization option is selected in configuration window from Syncfusion Blazor Template Studio wizard.

Register and Login Application

Individual Authentication

Blazor Web App

Applying Database Migrations and User Registration in the .NET 8.0 Blazor Web App
Applying Database Migrations:

In the Blazor Web App, it’s essential to apply pending migrations to the database before proceeding with user registration. Choose one of the following options:

Option 1: Using Visual Studio Package Manager Console

Navigate to View -> Other Windows -> Package Manager Console in Visual Studio.

Run the following command in the Package Manager Console:

Update-Database

Option 2: Using Command Prompt

Open a command prompt in your project directory and execute the following command:

dotnet ef database update

User Registration:
  1. Launch the application and register by submitting your email address and creating a password.

    Register the WebApp

  2. Confirm your registration by clicking Click here to confirm your account.

    Confirming the WebApp registration

  3. Submit your registered email address and password to log in to the application.

    LogIn to the WebApp

Server Application, ASP.NET Core hosted Web Application, and Progressive Web Application with ASP.NET Core hosted

  1. For register the application, submit your email address and create a password.

    Register the application

  2. Confirming registration by clicking Click here to confirm your account.

    Register the confirmation

  3. Submit your registered email address and password to login the application.

    login to the application

Web Application and Progressive Web Application

  1. Login to the application using Gmail accounts.

    Google login

Microsoft Identity Platform

Server Application, Web Application, Progressive Application, ASP.NET Core Hosted Web Application, and ASP.NET Core Hosted with Progressive Web Application

  1. Login to your application using your Microsoft account.

  2. Accept permission request of your application.

    Accept permission