Blash is a Twitter dashboard, written as a Blazor example to display real-time tweets from search queries of your choice.
It uses a number of Blazor components, using Razor to display the different components on the dashboard.
Blash is a Twitter dashboard, written as a Blazor example to display real-time tweets from search queries of your choice.
It uses a number of Blazor components, using Razor to display the different components on the dashboard.
The Blazor WebAssembly application integrates with an ASP.NET Core Web API. The Blazor application does an API call to get all the relevant information needed for the dashboard.
The Web API communicates with the Twitter API to search a list of recent tweets for a particular query. It uses Entity Framework Core to store this information in a SQL Server database, and returns this information to the Blazor application.
One of the important things with Blazor is it's ability to keep in sync with the most recent tweets. In-order to do this, it establishes a SignalR connection with the Web API. This means that the tweets are updated in real time, and any user that is viewing the dashboard will have the correct information.
When the Web API starts up, it runs a series of jobs in the background. These include:
Only when these jobs are completed does the Web API start running.
With the Blazor WebAssembly application, it calls an endpoint to get all the dashboards and the tweets that it belongs to.
In-addition, it establishes a WebSocket connection with SignalR through the Web API. The purpose of this connection is for the Blazor WebAssembly application to know when:
This is so it can update the dashboard in real-time.
This is the software that will need to be installed onto your machine.
These are the steps to get the application working.
Database
. Within that folder, there is a file called RoundTheCode_Blash.bak
. This needs to be imported as a database into your SQL Server.From there, you will need to update some settings to get the application working. You will need to open up the Web/RoundTheCode.Blash.Api/appsettings.json
file and change the following settings.
ConnectionStrings > BlashDbContext
.Api > TwitterApi > ClientId
.Api > TwitterApi > ClientSecret
.You are now ready to go.
Open up RoundTheCode.Blash.sln
in Visual Studio.
You will need to check that both the Blash API and the Blazor WebAssembly application are set up to run on startup.
Right-click on the solution and select "Set Startup Projects...".
Select Multiple startup projects, and for RoundTheCode.Blash.Api
and RoundTheCode.Blash.BlazorWasm
, make sure that the action is set to Start
.
Press OK to confirm the changes. Then start the project in Visual Studio.
You should find that the Web API runs on https://localhost:5001
, and the Blazor WebAssembly runs on https://localhost:5002
.
It's the Blazor WebAssembly application where you can view your Twitter Dashboard, so open up a browser and navigate to https://localhost:5002
.
Learn Blazor WebAssembly with our online courses