Blazor now in official preview!

Daniel Roth

Daniel

With this newest Blazor release we’re pleased to announce that Blazor is now in official preview! Blazor is no longer experimental and we are committing to ship it as a supported web UI framework including support for running client-side in the browser on WebAssembly.

A little over a year ago we started the Blazor experimental project with the goal of building a client web UI framework based on .NET and WebAssembly. At the time Blazor was little more than a prototype and there were lots of open questions about the viability of running .NET in the browser. Since then we’ve shipped nine experimental Blazor releases addressing a variety of concerns including component model, data binding, event handling, routing, layouts, app size, hosting models, debugging, and tooling. We’re now at the point where we think Blazor is ready to take its next step.

Blazor icon

Simplifying the naming and versioning

For a while, we’ve used the terminology Razor Components in some cases, and Blazor in other cases. This has proven to be confusing, so following a lot of community feedback, we’ve decided to drop the name ASP.NET Core Razor Components, and return to the name Server-side Blazor instead.

This emphasizes that Blazor is a single client app model with multiple hosting models:

  • Server-side Blazor runs on the server via SignalR
  • Client-side Blazor runs client-side on WebAssembly

… but either way, it’s the same programming model. The same Blazor components can be hosted in both environments.

Also, since Blazor is now part of .NET Core, the client-side Blazor package versions now align with the .NET Core 3.0 versions. For example, the version number of all the preview packages we are shipping today is 3.0.0-preview4-19216-03. We no longer use separate 0.x version numbers for client-side Blazor packages.

What will ship when

  • Server-side Blazor will ship as part of .NET Core 3.0. This was already announced last October.
  • Client-side Blazor won’t ship as part of the initial .NET Core 3.0 release, but we are now announcing it is committed to ship as part of a future .NET Core release (and hence is no longer an “experiment”).

With each preview release of .NET Core 3.0, we will continue to ship preview releases of both server and client-side Blazor.

Today’s preview release

New features in this preview release:

  • Templates updated to use the .razor file extension
  • _Imports.razor
  • Scope components with @using
  • New component item template
  • New Blazor icons
  • Blazor support in Visual Studio Code

Check out the ASP.NET Core 3.0 Preview 4 announcement for details on these improvements. See also the Blazor release notes for additional details on this preview release.

Get the Blazor preview

To get started with the Blazor preview install the following:

  1. .NET Core 3.0 Preview 4 SDK (3.0.100-preview4-011223)
  2. The Blazor templates on the command-line:

    dotnet new -i Microsoft.AspNetCore.Blazor.Templates::3.0.0-preview4-19216-03
    
  3. Visual Studio 2019 Preview with the ASP.NET and web development workload selected as well as the latest Blazor extension from the Visual Studio Marketplace, or Visual Studio Code with the latest C# extension (now with Blazor support!).

You can find getting started instructions, docs, and tutorials for Blazor at our new Blazor home page at https://blazor.net.

Blazor home page

Upgrade to the Blazor preview:

To upgrade your existing Blazor apps to the new Blazor preview first make sure you’ve installed the prerequisites listed above then follow these steps:

  • Update all Microsoft.AspNetCore.Blazor.* package references to 3.0.0-preview4-19216-03.
  • Remove any package reference to Microsoft.AspNetCore.Components.Server.
  • Remove any DotNetCliToolReference to Microsoft.AspNetCore.Blazor.Cli and replace with a package reference to Microsoft.AspNetCore.Blazor.DevServer.
  • In client Blazor projects remove the <RunCommand>dotnet</RunCommand> and <RunArguments>blazor serve</RunArguments> properties.
  • In client Blazor projects add the <RazorLangVersion>3.0</RazorLangVersion> property.
  • Rename all _ViewImports.cshtml files to _Imports.razor.
  • Rename all remaining .cshtml files to .razor.
  • Rename components.webassembly.js to blazor.webassembly.js
  • Remove any use of the Microsoft.AspNetCore.Components.Services namespace and replace with Microsoft.AspNetCore.Components as required.
  • Update server projects to use endpoint routing:
// Replace this:
app.UseMvc(routes =>
{
    routes.MapRoute(name: "default", template: "{controller}/{action}/{id?}");
});

// With this:
app.UseRouting();

app.UseEndpoints(routes =>
{
    routes.MapDefaultControllerRoute();
});
  • Run dotnet clean on the solution to clear out old Razor declarations.

Blazor community page is now Awesome Blazor

As part of updating the Blazor site, we’ve decided to retire the Blazor community page and instead direct folks to the community driven Awesome Blazor site. Thank you Adrien Torris for maintaining this truly “awesome” list of Blazor resources!

Try out preview Blazor UI offerings from Telerik, DevExpress, and Syncfusion

Blazor benefits from an active and supportive community that has contributed all sorts of sample apps, components, and libraries to the Blazor ecosystem. Recently popular component vendors like Telerik, DevExpress, and Syncfusion have joined in the fun and shipped previews of Blazor UI components. We encourage you to give these Blazor UI offerings a try and let them know what you think.

Give feedback

We hope you enjoy this latest preview release of Blazor. As with previous releases, your feedback is important to us. If you run into issues or have questions while trying out Blazor, file issues on GitHub. You can also chat with us and the Blazor community on Gitter if you get stuck or to share how Blazor is working for you. After you’ve tried out Blazor for a while please let us know what you think by taking our in-product survey. Click the survey link shown on the app home page when running one of the Blazor project templates:

Blazor survey

Thanks for trying out Blazor!

Daniel Roth
Daniel Roth

Principal Program Manager, ASP.NET

Follow Daniel   

78 comments

  • Troy Robinson
    Troy Robinson

    Glad to hear this, was worried that the news would be that the project was scrapped!  Awesome – can’t wait for JS to slowly go away.

  • Avatar
    Warren R

    Thank you for committing to this, really looking forward to coming back to C# for web development in the years to come.

  • Jiping
    Jiping

    Awesome Blazor awesome!
    Is there a rich starter kit, like those Bootstrap Admin Template, it will boost the community.

  • Avatar
    shiva prasanth

    personally i feel like this is revolution, same like when nodejs introduced which lets us run javascript in both server and browser.
    there are some projects like brython(runs python(syntax) on browser) but it won’t leverage webassembly.
    blazor using webassembly really boosts performance IMO.
    very very cool.

  • Ben Hayat
    Ben Hayat

    So Dan, what wasaccomplished or resolved in this preview that kicked Blazor out of experimental into offical product?

    Thanks!
    ..Ben

    • Daniel Roth
      Daniel Roth

      We’ve known for several months now that we wanted to ship Blazor based on the level of community interest and the results of our technical investigations. The main delay was to allow time to determine the roadmap for shipping Blazor. We’ve already announced that server-side Blazor will ship with .NET Core 3.0 later this year and we hope to share more details on the roadmap for the client-side WebAssembly support soon.

      • Avatar
        Juho Hanhimäki

        Hi Dan,
        Any updates on the roadmap for client-side WASM support? We’re planning to begin development on standalone client-side application and it would be greatly helpful if there was rough timeframes for RC (go live?) and GA releases?
        The current previews look very promising!

        • Daniel Roth
          Daniel Roth

          Nothing to share yet, unfortunately. Right now we’re almost entirely focuses on shipping support for Blazor Server apps in .NET Core 3.0. We have publicly announced that WebAssembly support will come with .NET 5 late next year. We’re still trying to figure out if/when we can shipping something earlier than that for folks to use.

          • Avatar
            Juho Hanhimäki

            Hopefully you can come up with some kind of interim release before the full .NET 5 release (.NET Core based WASM runtime?). Even the current previews work quite nicely and in our business the “it works” is the most important feature of a program. Finally having a Microsoft solution for client sided web development is very exciting and I think that is what has caused most of the hype behind Blazor. I feel like it would be a long wait for some of us to wait for .NET 5. 🙂

  • Avatar
    锦 王

    Thanks for your guys great jobs!
    I have one question: where is blazor library template in visual studio? or shoud i use blazorlib cli to generate blazor library project? or just use razor library project?

    • Avatar
      Chris Sainty

      The Blazor Library project is only available via the dotnet CLI templates. Whether you use a razor class library or blazor library depends on what you need. Razor class libraries will work fine with server-side Blazor but if you need to include static assets then you should continue to use a Blazor library. However, static assets still don’t work with server-side Blazor pending the resolution of https://github.com/aspnet/AspNetCore/issues/6349. Hope that makes sense.

    • Daniel Roth
      Daniel Roth

      .NET Core 3.0 is still in preview as is server-side Blazor. It’s expected to ship in the second half of 2019. But once .NET Core 3.0 is go live that will include server-side Blazor

  • Adrian Cockburn
    Adrian Cockburn

    Great news!

    You should add that services.AddRazorComponents need to be changed to services.AddServerSideBlazor for server side startup.cs.

  • Ben Hayat
    Ben Hayat

    Hi Dan;

    In the last .Net standup session, when you asked steve about the the direction of Auth, he said he is planning to piggypack on the existing [old] Auth system where we have to store user’s data/password in our database and be responsible for it. I’m sure many hackers were pleased to hear that, as lots opportunities will open up.

    That was disturbing to hear as security is very important, and it is still being neglected with the lastest technology from MSFT.

    My humble request is to at least give us an easy and clean way to use Azure B2C in both types of hostings, where we can use B2C from server side rendered code and how to deal with tokens and the client side Blazor to obtain tokens, send it to backend Web API.

    We either need to have a built in system in Blazor or the least a full guideline/best practices how to use Blazor with B2C.

    Thank you for your hard work Dan;
    ..Ben

  • Ben Hayat
    Ben Hayat

    Hi Dan;

    Are we still missing tooling in the VS19 to create a Blazor page (xys.razor)? The included template to create “Razor” page seems to be creating the ASP.Net razor page and not for Blazor.
    I looked at the roadmap for Preview 6 and didn’t see any mention of this tooling.
    Thanks!
    ..Ben

    • Daniel Roth
      Daniel Roth

      We don’t have a component item template in Visual Studio yet, but we should have it soon. In this release we added the component item template to the .NET Core 3.0 SDK, which will then be used to add the item template in Visual Studio.

  • Avatar
    Sarathlal Saseendran

    Hi, Thanks for the great information. How can we use HttpClient in this new Blazor? Any sample code available?

  • Avatar
    Jeremy Knaggs

    This is seriously fantastic. I’m really thinking this type of tech will be what brings about the next era of web development. Keep up the fantastic work and a million thanks to entire Blazor team!

  • Avatar
    新民 黄

    Why not give Server-side Blazor a brand new and unique name, such as Blazerver (Blazor + Server), this makes it short and recognizable, and the new name mostly helps when developers use search engine to solve problems. 
    And Client-side Blazor can named Blazent also. 🙂

  • Avatar
    Anderson Moscarelli

    I have a client server blazor project and these properties <RunCommand>dotnet</RunCommand> and <RunArguments>blazor serve</RunArguments> , <RazorLangVersion>3.0</RazorLangVersion> are not present in anyware and i have no clue where to put <RazorLangVersion>3.0</RazorLangVersion>  . Can you advice?

    • Daniel Roth
      Daniel Roth

      The RazorLangVersion property should be added in a PropertyGroup in your client csproj file. You should also remove the RunCommand and RunArguments properties from your client csproj file if you have them.

  • Avatar
    remi bourgarel

    If you want to rename all your project file, user the following powershell

    Get-ChildItem -Path . -Filter *.cshtml -Recurse | Rename-Item -NewName{[System.IO.Path]::ChangeExtension($_.Name, “.razor”)}

  • Avatar
    Ross Jempson

    This sounds like Silverlight without a plugin?  When strategy changes, and resources have been prioritised for other things, and the project is retired by Microsoft, is it likely to become a community open source project.  In other words, if someone was to invest time learning this framework and build production software upon it, is there any chance that will backfire?

    • Daniel Roth
      Daniel Roth

      Blazor is .NET in the browser without any plugins or code transpilation; just open web standards. It’s already an open source, community driven project that is part of the .NET Foundation. So, if Microsoft decides to move onto something else, the community can always take up the reigns and keep it going. 

  • Avatar
    Evaldas Jocys

    Good effort. Problem is that downloading NuGet packages and providing examples which can’t simply run in the browser will result in many developers just ignoring this technology. Running C# in web browser must be simple as running single Example.html file from the local disks:
    <html><head>    <script type=”text/csharp”>        void Add(x, y)        {            var value = x + y;            document.getElementById(“Result”).value = value;        }    </script></head><body>    <input type=”text” id=”Result” />    <button onclick=”Add(1, 2)”>Calculate</button></body></html>

    • Daniel Roth
      Daniel Roth

      We are working hard to make the getting started experience with Blazor as simple as possible. While we’d love for .NET and C# to have a more native experience in the browser like JavaScript enjoys, we are limited by what browsers support today. Blazor is more comparable to existing frontend UI frameworks like Angular, React, or Vue. These frameworks have rich component models and include more machinery for building large scale applications.

  • thiyagu Raj
    thiyagu Raj

    Awesome MS ,, i am following webassembly last 6 years when it was announced and MS pickup and finally its ready , waiting to code a browser behaviors in c#,, 

  • Avatar
    Frank Thomas

    I agree, it does look promising. I think my main question is how does it compare to the likes of Angular and React, or is there a comparison?

  • Avatar
    Agustin Silva

    We are  loving blazor. Thanks.  After the update we are getting lots of errors:
    The type or namespace name ‘Mvc’ does not exist in the namespace ‘Microsoft.AspNetCore’ , any suggestions?

  • Avatar
    Michael Easterbrook

    I have a website built with Razor. How difficult would it be to convert it to Blazor? It uses C# and the backend is SQL Server.

    • Daniel Roth
      Daniel Roth

      You should first consider if porting your existing app to Blazor is really necessary. Razor today is used for server-side rendering of HTML, while Blazor is intended for client-side web UI. The scenarios are different and complimentary. In ASP.NET Core apps, you can add Blazor components to your existing Razor Pages and MVC Views. There’s no need to rewrite your entire app using Blazor. In many cases, using server-side rendering is simpler and preferable. 

  • Avatar
    jorge arana

    unfortunately I have started learning blazor a week ago, using .net core 3.0 and official blazor preview where it is not possible to connect to a database using Microsoft.EntityFrameworkCore.SqlServer. Before it was very easy to connect in asp.net MVC. Now I see that this is not possible.
    The MSB3073 error appears
    I have seen your comment on github:”The issue you are seeing is due to the IL Linker complaining about a native dependency in your dependency graph (probably from microsoft.entityframeworkcore.sqlserver in this case). Native dependencies will not work when running on WebAssembly (for obvious reasons), so if you want to run client-side then you should clean up your dependencies to just the stuff that can work in a browser.
    I must understand that the case is closed and it is not possible to work with a data server.

    • Daniel Roth
      Daniel Roth

      Hi Jorge, 

      Blazor for WebAssembly runs client-side in the browser in the normal browser security sandbox. You don’t typically connect directly to your database from the browser. Instead you build an HTTP service on the server that talks to the database that the browser app can then call.

      With server-side Blazor the situation is a bit different because your components are running on the server and can therefor can talk directly to a database. However, with server-side Blazor you also pay the cost on your servers of running the UI for each connected client, so it’s a tradeoff.

      I hope this helps!

  • Avatar
    Hitesh Davey

    Hi Daniel, I understand that C# & VB.NET compilers are based on common compiler platform called “Roslyn” and both languages compile code into common IL for execution; then what is so hard for MS to enable the development of Blazer/Xamarin/cross-platform apps using VB.NET? I am sure the entire VB.NET developer community would be interested to know more about this in detail. Pl don’t disappoint us!

    • Daniel Roth
      Daniel Roth

      The .NET runtime used by Blazor runs normal .NET assemblies, so you can run code written in VB or other .NET languages from a Blazor app by factoring that code out into separate projects. However, the Blazor app project typically needs to be a csproj because the Razor files used to author components are a combination of C# and HTML that compile to C# classes. We don’t plan to support other languages in Razor files because of the cost involved with supporting multiple versions of the Razor compiler and related tooling.

  • Avatar
    Ra D

    Hi Dan, Blazor looks very promising. Can you include Authentication into .NetCore Preview3 VS2019 templates. I like the Blazor server-side model, it has a simple and clean code layout and foot print; however injecting authentication seem to be a pain so far. Having a solid individual user (user registration) code template would simplify our Blazor development.  Thanks

    • Daniel Roth
      Daniel Roth

      Absolutely, we’re enabling authentication for Blazor, including enabling the authentication options for the server-side Blazor template, in .NET Core 3.0 Preview6, which ships later this month.

    • Avatar
      Michael DeMond

      +1 for the server-side WebSocket-based model.  IMO, this is an underrated and under-promoted/marketed feature.  WebAssembly is great and all, but it’s new and carries a lot of unknowns/risk/cost.  Not to mention the payload to download.  Having the ability to drop back into WebSockets is more traditional and familiar.  I’ve been studying Blazor for the past few days around this area and have been very impressed.  For all intents and purposes, .NET is truly back in the browser and all is right in the world again.  Super props, recognition, and respect to the entire team there — especially to Mr. Roth who has done an excellent job engaging customers and developers here on the blog and in GitHub.

  • Avatar
    Agung Buana

    I just downloaded vs 2019 16.2 preview 2 and netcore 3 preview6. I couldn’t find Razor Components template. So what is the official name of the template? is it Blazor (server-side) now?

    • Daniel Roth
      Daniel Roth

      Correct, the Razor Components template was renamed to “Blazor (server-side)”.

      Also, just a heads up, we plan to rename it again (last time, I promise!) to Blazor Server App in a future update.

  • Avatar
    Dharmraj

    Hello Roth,I can see the future, it would be the new era of web development by this amazing feature and invention of Blazor. Its really nice and i am sure most of i.t. proffessionals will move to use Blazor for making SPA.Also please solve my prob,Using: visual studio code + latest C# extension. OS: windows 10 – 64biti have made .net core app wit blazor, this throws error while i build the app [appname: CodeCoreBlazor]:Error:
    C:\Program Files\dotnet\sdk\3.0.100-preview6-012264\Microsoft.Common.CurrentVersion.targets(4552,5): error MSB3027: Could not copy “D:\TestProjects\New folder\CodeCoreBlazor\obj\Debug\netcoreapp3.0\CodeCoreBlazor.exe” to “bin\Debug\netcoreapp3.0\CodeCoreBlazor.exe”. Exceeded retry countof 10. Failed. [D:\TestProjects\New folder\CodeCoreBlazor\CodeCoreBlazor.csproj]
    C:\Program Files\dotnet\sdk\3.0.100-preview6-012264\Microsoft.Common.CurrentVersion.targets(4552,5): error MSB3021: Unable to copy file “D:\TestProjects\New folder\CodeCoreBlazor\obj\Debug\netcoreapp3.0\CodeCoreBlazor.exe” to “bin\Debug\netcoreapp3.0\CodeCoreBlazor.exe”. The process cannot access the file ‘D:\TestProjects\New folder\CodeCoreBlazor\bin\Debug\netcoreapp3.0\CodeCoreBlazor.exe’ because it is being used by another process. [D:\TestProjects\New folder\CodeCoreBlazor\CodeCoreBlazor.csproj]
    The build failed. Fix the build errors and run again.Please solve my prob, i have done much r&d on internet, not getting the solution. Thanks.

    • Daniel Roth
      Daniel Roth

      Hi Dharmraj. Thanks for trying Blazor! It looks like the build failed because the the app is currently running and as a result the binaries are locked. Make sure the app isn’t running and then try building again.

  • Avatar
    Dharmraj

    Hey roth, is it possible to make progressive web app with blazor??  
     If not, then please make it possible, so that blazor can be bomb blastic and extreme competeiter to react, angular and other spa frameworks.  Thanks.

    • Daniel Roth
      Daniel Roth

      Hi Parimal. Blazor is still in preview. Support for Blazor Server Apps is shipping with .NET Core 3.0 later this year in September. Support for Blazor WebAssembly Apps will ship some time later (exact date still to be determined). We have announced publicly that .NET support for WebAssembly will be part of the .NET 5 release late next year.

    • Daniel Roth
      Daniel Roth

      Hi Dzmitry,

      While Blazor shares some similarities with Silverlight in that both are technologies that let you run .NET in a web browser, they have several key differences:

      – Blazor is based on WebAssembly, an open web standard and doesn’t require a browser plugin

      – Blazor’s UI model is based on HTML & CSS instead of XAML

      – Blazor is an open source and community based project. Even if Microsoft were to lose interest in the community can continue to carry it forward.

      I hope this helps!

      Daniel Roth

    • Daniel Roth
      Daniel Roth

      Hi Suhail.

      Support for Blazor Server apps is shipping with .NET Core 3.0 later this month. Be sure to join us for the release announcement at .NET Conf!

      Blazor WebAssembly support is not shipping with .NET Core 3.0, but we are continuing to work on it in parallel and we hope to share more details on its exact roadmap soon.

Leave a comment