JoBo
JoBo

Reputation: 347

Check if Blazor app is WebAssembly or Server?

Started a project via cmd so not sure if it is a WebAssembly App or Server side app.

Anybody know how to check this in an easy way in Visual Studio/cmd?

Upvotes: 17

Views: 10400

Answers (4)

Henk Holterman
Henk Holterman

Reputation: 273494

Update (.net 5 and up)

The quickest way is to look in Program.cs

Blazor WebAssembly:

var builder = WebAssemblyHostBuilder.CreateDefault(args);

Blazor Server:

var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();

also, the presence of any .cshtml files, mainly Pages\_Host.cshtml, means it is a Blazor Server project.

Old answer

There are several points in the project you can easily check.

Look for the line services.AddServerSideBlazor(); in ConfigureServices()

Upvotes: 15

RicZ
RicZ

Reputation: 21

You could check it by running the app in localhost and then checking the initiator in network traffic when the app launches.

Upvotes: 0

Andrew Malkov
Andrew Malkov

Reputation: 216

You can open the .csproj file and look at the first line. Blazor Server App project is using Sdk="Microsoft.NET.Sdk.Web" but Blazor WebAssembly App is using Sdk="Microsoft.NET.Sdk.BlazorWebAssembly".

Upvotes: 20

enet
enet

Reputation: 45684

If three projects (.Client, .Server, .Shared) were created, this is a WebAssembly Blazor App hosted (on the server).

If a single project was created, it might be a WebAssembly Blazor stand alone App, or a Blazor Server App. In that case you should look for the Startup class. If exists, that means that your project is a Blazor Server App, if not then it is a WebAssembly Blazor stand alone. This is basically how I often view the structure of my solution, by a quick scan.

Upvotes: 4

Related Questions