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:

12229 questions
131
votes
6 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
  • 3,676
  • 4
  • 28
  • 39
112
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
  • 6,894
  • 3
  • 22
  • 41
110
votes
6 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
  • 589
  • 3
  • 7
  • 26
110
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
  • 3,126
  • 4
  • 31
  • 57
108
votes
5 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
  • 2,054
  • 4
  • 11
  • 34
105
votes
6 answers

NavigationManager - 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.
  • 1,159
  • 2
  • 8
  • 5
94
votes
3 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,418
  • 3
  • 41
  • 39
84
votes
6 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
  • 8,794
  • 17
  • 73
  • 152
82
votes
6 answers

Sending Push Notifications to iOS from PWA

I've got a Progressive Web App which made with Blazor WebAssembly and I was wondering if I can send push notifications to iOS devices? Although people said if works now on Safari on MacOS, Push API's website says that it does not support Safari on…
76
votes
6 answers

Why are Blazor lifecycle methods getting executed twice?

So with a release of asp.net core 3.0 and blazor 1.0 I started doing some actual work with blazor. When splitting Blazor component code into code behind I am using the following public class LogoutModel : BlazorComponent { } Unfortunately…
mko
  • 6,638
  • 12
  • 67
  • 118
73
votes
9 answers

How to enable/disable inputs in blazor

I am trying to Enable/Disable a group of time inputs in Blazor based on a checkbox ; while for inputs of type button the below solution works ,for inputs of type time it doesn't : Solution for button input that works:
72
votes
2 answers

When should I call StateHasChanged and when Blazor automatically intercepts that something is changed?

I am having a hard time understanding when I should call StateHasChanged() and when Blazor intercepts that something is changed so it must be re-rendered. I've created a sample project with a button and a custom component called AddItem. This…
Leonardo Lurci
  • 2,409
  • 3
  • 18
  • 34
71
votes
14 answers

Get Current User in a Blazor component

I'm starting a new site with Blazor and Windows Authentication and need to identify the current user viewing the page/component. For a Razor Page, the current user name can be accessed with Context.User.Identity.Name, but that doesn't seem to work…
Wes H
  • 4,186
  • 2
  • 13
  • 24
69
votes
6 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
  • 1,195
  • 1
  • 11
  • 17
1
2 3
99 100