Questions tagged [blazor]

Blazor lets you build interactive web UIs using C# instead of JavaScript. It is a feature of ASP.NET, the web development framework from Microsoft that extends the .NET developer platform.

Blazor is a framework whose goal is to enable developers to write client-side code in .NET, backed by WebAssembly or by SignalR.

Blazor lets you build interactive web UIs using C# instead of JavaScript. Blazor apps are composed of reusable web UI components implemented using C#, HTML, and CSS. Both client and server code is written in C#, allowing you to share code and libraries.

It extends the established Razor syntax to let developers write client-side markup and connect its elements to data and methods defined on models written in C#.

This tag should be used for questions that are specific to this usage of Razor.

Useful links:

5740 questions
89
votes
3 answers

Blazor performance

I would like to start using Blazor, despite the fact that it is still at the alpha level. As I understand it, Blazor uses WebAssembly to compile C# on the client side. And I have these questions: Does this approach run faster than, for example,…
FoxPro
  • 1,379
  • 3
  • 8
  • 20
74
votes
2 answers

Is there an equivalent to Html.Raw in Blazor?

I have some HTML that is stored in a string. How can I render it in a Blazor/Razor view without automatic HTML encoding?
Dave
  • 2,582
  • 3
  • 21
  • 31
71
votes
4 answers

Blazor how to pass arguments to onclick function?

I'd want to make button onclick function that takes some input. @functions { public void test(int a, int b) { Console.WriteLine(a + b); } } But for some reason it throws an…
Axelly
  • 955
  • 1
  • 6
  • 17
71
votes
7 answers

How to fix "The CORS protocol does not allow specifying a wildcard (any) origin and credentials at the same time" error

I've already enabled CORS on the project in C# .net Core In startup.cs I've added lines ... services.AddCors(); ... app.UseCors(builder => builder .AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials()); But when…
Igor Cova
  • 2,074
  • 2
  • 20
  • 48
67
votes
2 answers

Blazor vs Razor

With the invention of Blazor, I'm wondering if there are significant efficiencies (both in creation of code and in the actual compilation / execution of code) between these two languages? https://github.com/SteveSanderson/Blazor If anyone has…
benpage
  • 4,071
  • 3
  • 38
  • 39
59
votes
5 answers

Why does page not update after refresh when .cshtml changes

I am trying out Blazor and i do not understand why when changing a component after refreshing the browser page it does not update ? Shouldn't the client update itself similar to how angular does? It only refreshes when i restart the blazor…
Bercovici Adrian
  • 6,415
  • 9
  • 47
  • 90
48
votes
6 answers

What's the difference between ASP.NET Core Hosted and Server-Side Blazor, really?

I'm still struggling to understand the difference between ASP.NET Core Hosted and Server-side Blazor. I know same question already exists, but it's not satisfying. In fact, I couldn't find the satisfying answer anywhere - the answers were more or…
JohnyL
  • 5,988
  • 2
  • 15
  • 33
47
votes
3 answers

Get current URL in a Blazor component

I need to know the URL of the current page in order to check if I have to apply a certain style to an element. The code below is an example. @using Microsoft.AspNetCore.Blazor.Services @inject IUriHelper UriHelper @implements…
Carlos L.
  • 479
  • 1
  • 4
  • 5
43
votes
5 answers

How can one generate and save a file client side using Blazor?

I want to have a SPA that's doing all the work client side and even generating some graphs/visuals. I'd like to be able to have the user click buttons and save the visuals, tables, and other things from the page (that are both seen and not seen, so…
shawn.mek
  • 915
  • 1
  • 9
  • 17
41
votes
4 answers

Blazor onchange event with select dropdown

So I have been stuck trying to get a simple onchange to fire when a select dropdown value changes. Like so: