• This repository has been archived on 08/Jan/2021
  • Stars
    star
    131
  • Rank 275,867 (Top 6 %)
  • Language
    C#
  • Created over 7 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Blazor is now official and is part of the ASP.NET Core Framework. All the work is tracked in the dotnet/aspnetcore repo.

Blazor

An experimental web UI framework using C#/Razor and HTML, running client-side via WebAssembly

The arrival of WebAssembly creates the possibility of building client-side web applications using languages and runtimes that are more typically used for native app development. Blazor runs .NET code in the browser via a small, portable .NET runtime called DotNetAnywhere (DNA) compiled to WebAssembly.

The programming model will be familiar to anyone who's worked with Razor (the C#/HTML page format used by ASP.NET MVC and ASP.NET Pages).

To get started building an app or working on Blazor itself, see Getting Started.

Questions

Could something like this really be practical? How big would the apps be to download?

Yes, it could be practical. A "hello world" app that runs Razor in the browser with this template is around 300KB, which is smaller than typical apps from some other single-page-app (SPA) frameworks. That 300KB includes everything: the small .NET runtime, core libraries, application code, and wrapper libraries needed to bootstrap and interop with the WebAssembly code.

That's before any real optimisation attempt. If there was a proper attempt at code stripping to remove all non-called corlib code, it could get smaller.

What about browsers that don't support WebAssembly?

It still works fine there too. WebAssembly is designed to fall back on a JavaScript polyfill easily. The template in this repo automatically detects if the browser doesn't support WebAssembly, and loads an asm.js version instead. Performance is still surprisingly good.

Is this actually .NET in the browser?

It's not the regular .NET Framework or .NET Core runtime. It's a third-party .NET runtime called DotNetAnywhere, which has been updated and extended in various ways to support being compiled to WebAssembly, to load and run .NET Core assemblies, and with some additional functionality such as basic reflection and so on.

Can I build a real production app with this?

No. It's incredibly incomplete. For example, many of the .NET APIs you would expect to be able to use are not implemented.

Why isn't there an issue tracker? How do I file issues?

You don't file issues. There's no support for this. It's experimental.

If you would like to contribute, you can submit a pull request though.

Why does this exist?

To see how well such a framework might work, and how much anyone would care. Note that it's a personal project rather than an official Microsoft project.

Getting started

You can either build an app with Blazor, or you can hack on Blazor itself.

Building an app with Blazor

Install the VS extension, then use File->New project, and choose Blazor Application from the Web category.

To start the application in VS, just press F5 or Ctrl+F5 as usual.

To start the application on the command line, run dotnet blazor serve.

Once your app is running, you can edit its cshtml files, and the application will update automatically.

This project template gives you a standalone Blazor application. That is, it's not hosted on an ASP.NET server (at least, not one you can see). The idea is that ultimately you could deploy your client-side Blazor app as a set of purely static files that could be served from any web technology (Rails, PHP, a static file host, etc.). Therefore, server-side prerendering is not supported in this mode.

If you want to see a Blazor app hosted within an ASP.NET server, with server-side prerendering support, see the ClientServerApp sample mentioned in the next section.

What about cross-platform CLI developers?

This should all work on Linux/macOS since .NET Core is cross platform, but I just haven't made a dotnet new template for it yet.

Hacking on Blazor itself

If you want to extend Blazor itself, the setup is a bit more involved.

Prerequisites

  • .NET Core 2.0 preview 3 or later. I've been using SDK build 6764.
  • Visual Studio 2017.3 or later. I've been using VS2017.3 Preview 3 and Preview 4. Older preview versions don't work.

Instructions

  • Clone this repo
  • In a command prompt at the root of the repo, run dotnet restore Blazor.Core.sln
  • Now open Blazor.Core.sln in VS2017.3
  • Expand samples, then ClientServerApp, then right click on ClientServerApp.Server and choose "Set as StartUp Project".
  • Launch the application using Ctrl+F5

You can now work on the sample application, or modify the Blazor runtime, compiler, host, or the corlib project. You can also debug into any of these projects when they executing on the server (e.g., during runtime Razor compilation or server-side prerendering).

Warning: For some reason it seems necessary to use Rebuild all after making changes to the Blazor projects: just building the sample application alone doesn't get the changes, even though it has a project reference to the Blazor library projects. Let me know if you can solve this!

Hacking on the DNA runtime

If you want to make changes to the DNA runtime itself, which is written in C and compiled with Emscripten (for example, to support new corlib features), see these instructions.

Working on the project template and Visual Studio extension

The project template and VS extension are in a different solution, Blazor.ProjectTemplate.sln. This is because the project template project needs to reference the Blazor libraries via NuGet package references, not project references, because it depends on <DotNetCliToolReference>. So, it can only be compiled once you've built the *.nupkg files for the Blazor packages. To do this:

  • At the project root, run dotnet restore Blazor.Core.sln if you didn't already
  • Run build-packages.cmd to create a set of NuGet package files in your local artifacts dir
  • Run dotnet restore Blazor.ProjectTemplate.sln so it picks up your new nupkg files
  • Optionally, if you want a .vsix file you could redistribute, run build-vsextension.cmd. The .vsix file will appear in your artifacts directory.

Now you can open Blazor.ProjectTemplate.sln in Visual Studio. If your VS instance doesn't already have the Visual Studio extension development toolset installed, it will prompt you to install that. And yes, you do actually need to do that.

Finally, you can either:

  • Set the MyApplication project as the startup project and launch it (Ctrl+F5) as a standalone app. This is equivalent to what a developer will get when they create a project with the template.
  • Or, set the Blazor.VSExtension project as the startup project and launch it (Ctrl+F5). This will launch the Visual Studio Experimental instance with the project template installed into it, so you can create a new project with it.

More Repositories

1

Mvc

[Archived] ASP.NET Core MVC is a model view controller framework for building dynamic web sites with clean separation of concerns, including the merged MVC, Web API, and Web Pages w/ Razor. Project moved to https://github.com/aspnet/AspNetCore
C#
5,617
star
2

JavaScriptServices

[Archived] This repository has been archived
C#
3,035
star
3

KestrelHttpServer

[Archived] A cross platform web server for ASP.NET Core. Project moved to https://github.com/aspnet/AspNetCore
C#
2,629
star
4

SignalR

[Archived] Incredibly simple real-time web for ASP.NET Core. Project moved to https://github.com/aspnet/AspNetCore
C#
2,381
star
5

Identity

[Archived] ASP.NET Core Identity is the membership system for building ASP.NET Core web applications, including membership, login, and user data. Project moved to https://github.com/aspnet/AspNetCore
C#
1,961
star
6

Announcements

Subscribe to this repo to be notified about major changes in ASP.NET Core and Entity Framework Core
1,658
star
7

MusicStore

[Archived] MusicStore test application that uses ASP.NET/EF Core. Project moved to https://github.com/aspnet/AspNetCore
1,298
star
8

Security

[Archived] Middleware for security and authorization of web apps. Project moved to https://github.com/aspnet/AspNetCore
C#
1,270
star
9

AspLabs

Repo for ASP.NET experiments that are not ready for a production release
C#
1,224
star
10

Benchmarks

Benchmarks for ASP.NET Core
C#
1,169
star
11

samples

Samples for ASP.NET Core
983
star
12

AspNetKatana

Microsoft's OWIN implementation, the Katana project
C#
966
star
13

dnx

OBSOLETE - see readme
C++
963
star
14

Razor

[Archived] Parser and code generator for CSHTML files used in view pages for MVC web apps. Project moved to https://github.com/aspnet/AspNetCore
C#
883
star
15

DependencyInjection

[Archived] Contains common DI abstractions that ASP.NET Core and Entity Framework Core use. Project moved to https://github.com/aspnet/Extensions
C#
873
star
16

AspNetWebStack

ASP.NET MVC 5.x, Web API 2.x, and Web Pages 3.x (not ASP.NET Core)
C#
853
star
17

SignalR-samples

Samples for ASP.NET Core SignalR
JavaScript
748
star
18

aspnet-docker

[Archived] ASP.NET Core Docker images for 1.x. Go to https://github.com/dotnet/dotnet-docker for 2.1 and up.
719
star
19

WebHooks

[Archived] Libraries to create and consume web hooks on ASP.NET Core. Project moved to https://github.com/aspnet/AspLabs
C#
627
star
20

Entropy

A chaotic experimental playground for new features and ideas - check here for small and simple samples for individual features.
C#
560
star
21

Hosting

[Archived] Code for hosting and starting up an ASP.NET Core application. Project moved to https://github.com/aspnet/Extensions and https://github.com/aspnet/AspNetCore
C#
552
star
22

Logging

[Archived] Common logging abstractions and a few implementations. Project moved to https://github.com/aspnet/Extensions
C#
506
star
23

Caching

[Archived] Libraries for in-memory caching and distributed caching. Project moved to https://github.com/aspnet/Extensions
C#
480
star
24

LibraryManager

C#
457
star
25

DotNetTools

[Archived] Various .NET command line tools. Project moved to https://github.com/aspnet/AspNetCore
C#
439
star
26

HttpAbstractions

[Archived] HTTP abstractions such as HttpRequest, HttpResponse, and HttpContext, as well as common web utilities. Project moved to https://github.com/aspnet/AspNetCore
C#
382
star
27

WebSockets

[Archived] Implementation of the WebSocket protocol, along with client and server integration components.
C#
357
star
28

Microsoft.Data.Sqlite

[Archived] SQLite implementations of the System.Data.Common interfaces. Project has moved to https://github.com/aspnet/EntityFrameworkCore
C#
347
star
29

AzureSignalR-samples

Code samples for Azure SignalR
JavaScript
327
star
30

Configuration

[Archived] Interfaces and providers for accessing configuration files. Project moved to https://github.com/aspnet/Extensions
C#
327
star
31

live.asp.net

Code for live.asp.net, which hosts the ASP.NET Community Stand-up
C#
289
star
32

Routing

[Archived] Middleware for routing requests to application logic. Project moved to https://github.com/aspnet/AspNetCore
C#
272
star
33

Tooling

Issue tracker and info on Visual Studio tooling for ASP.NET
256
star
34

jquery-validation-unobtrusive

Add-on to jQuery Validation to enable unobtrusive validation options in data-* attributes.
JavaScript
254
star
35

HttpClientFactory

[Archived] Contains an opinionated factory for creating HttpClient instances. Project moved to https://github.com/aspnet/Extensions
C#
252
star
36

AspNetIdentity

ASP.NET Identity for ASP.NET 4.x applications
C#
246
star
37

Diagnostics

[Archived] Diagnostics middleware for reporting info and handling exceptions and errors in ASP.NET Core, and diagnosing Entity Framework Core migrations errors. Project moved to https://github.com/aspnet/AspNetCore
C#
213
star
38

MetaPackages

[Archived] NuGet meta packages. Project moved to https://github.com/aspnet/AspNetCore
C#
211
star
39

Templating

[Archived] ASP.NET Core templates for .NET CLI and Visual Studio. Project moved to https://github.com/aspnet/AspNetCore
C#
205
star
40

Proxy

[Archived] Proxy library for ASP.NET Core. Project moved to https://github.com/aspnet/AspLabs
C#
201
star
41

dnvm

OBSOLETE - see readme
PowerShell
174
star
42

FileSystem

[Archived] Abstraction of file system APIs. Project moved to https://github.com/aspnet/Extensions
C#
171
star
43

BasicMiddleware

[Archived] Basic middleware components for ASP.NET Core. Project moved to https://github.com/aspnet/AspNetCore
C#
169
star
44

BugTracker

OBSOLETE - see readme
JavaScript
158
star
45

Universe

[Archived] Repo for building the entire ASP.NET and Entity Framework stack. Project moved to https://github.com/aspnet/AspNetCore
C#
158
star
46

Localization

[Archived] Localization abstractions and implementations for ASP.NET Core applications. Project moved to https://github.com/aspnet/AspNetCore
C#
157
star
47

Templates

This repo is OBSOLETE - please see the README file for information
C#
151
star
48

Options

[Archived] A framework for accessing and configuring POCO settings. Project moved to https://github.com/aspnet/Extensions
C#
149
star
49

IISIntegration

[Archived] ASP.NET Core IIS integration. Project has moved to https://github.com/aspnet/AspNetCore
C++
148
star
50

jquery-ajax-unobtrusive

[Maintenance mode: only security and critical bug fixes are being worked on] Add-on to jQuery Ajax to enable unobtrusive options in data-* attributes.
JavaScript
144
star
51

SignalR-Client-Cpp

C++ Client for ASP.NET Core SignalR
C++
140
star
52

AspNetWebHooks

Libraries to create and consume web hooks on ASP.NET 4.x (Due to other priorities this project is currently in maintenance mode only. There are no planned releases at this time. No new features are planned and we are only addressing critical issues as required.)
C#
135
star
53

Blazor.Docs

Docs for Blazor
CSS
131
star
54

DataProtection

[Archived] Data Protection APIs for protecting and unprotecting data. Project moved to https://github.com/aspnet/AspNetCore
C#
130
star
55

Session

[Archived] Session state middleware for ASP.NET Core. Project moved to https://github.com/aspnet/AspNetCore
C#
126
star
56

MicrosoftConfigurationBuilders

Microsoft.Configuration.Builders
C#
121
star
57

DataAccessPerformance

Benchmarks, prototypes and discussions for database access performance investigation
C#
115
star
58

AspNetCoreModule

ASP.NET Core Module for IIS and IIS Express
C#
115
star
59

StaticFiles

[Archived] Middleware for handling requests for file system resources including files and directories. Project moved to https://github.com/aspnet/AspNetCore
C#
114
star
60

HttpSysServer

[Archived] A web server for ASP.NET Core based on the Windows Http Server API. Project moved to https://github.com/aspnet/AspNetCore
C#
106
star
61

JsonPatch

[Archived] JSON PATCH library. Project moved to https://github.com/aspnet/AspNetCore
C#
103
star
62

CORS

[Archived] Implementations of common CORS policy and CORS middleware. Project moved to https://github.com/aspnet/AspNetCore
C#
90
star
63

RoslynCodeDomProvider

Roslyn CodeDOM provider
C#
84
star
64

AuthSamples

[Archived] Samples for ASP.NET Core authentication and authorization. Project moved to https://github.com/aspnet/AspNetCore
C#
83
star
65

Razor.VSCode

[Archived] This repo has been migrated. Please use the https://github.com/aspnet/AspNetCore repo instead.
C#
81
star
66

Antiforgery

[Archived] AntiForgery token feature for ASP.NET Core. Project moved to https://github.com/aspnet/AspNetCore
C#
78
star
67

BuildTools

Infrastructure utilities used in the ASP.NET Core build system. (Obsolete: use https://github.com/dotnet/arcade for all new projects)
C#
73
star
68

ResponseCaching

[Archived] ASP.NET Core middleware for caching responses. Project moved to https://github.com/aspnet/AspNetCore
C#
70
star
69

Testing

[Archived] Testing infrastructure, including support for xUnit.net and StyleCop. Project moved to https://github.com/aspnet/Extensions
66
star
70

SignalR-Client-JS

OBSOLETE - see readme
59
star
71

SignalR-Client-Net

OBSOLETE - see readme
57
star
72

AspNetSessionState

ASP.NET Session State (not for ASP.NET Core)
C#
55
star
73

NerdDinner

Porting NerdDinner to ASP.NET 5
JavaScript
50
star
74

SignalR-Redis

OBSOLETE - see readme
C#
48
star
75

EventNotification

[Archived] Event notification system for broadcasting application state and configuration. Project moved to https://github.com/aspnet/Extensions
C#
45
star
76

SignalR-SqlServer

OBSOLETE - see readme
C#
42
star
77

MvcPrecompilation

[Archived] Tooling that allows compilation of MVC Razor views as part of build and publish. Project moved to https://github.com/aspnet/AspNetCore
C#
42
star
78

KoreBuild

OBSOLETE REPO - see readme
Shell
37
star
79

vsweb-publish

Web publish support for ASP.NET 5 in Visual Studio 2015
PowerShell
33
star
80

homebrew-dnx

OBSOLETE - see readme
Ruby
32
star
81

Coherence

A build that verifies that all the packages form a consistent graph.
C#
30
star
82

AspNetWebFormsDependencyInjection

Dependency injection support for ASP.NET Web Forms 4.x
C#
30
star
83

UserSecrets

Command line tool and configuration provider for managing secrets
28
star
84

HtmlAbstractions

[Archived] HTML abstractions used for building HTML content. Project moved to https://github.com/aspnet/AspNetCore
C#
27
star
85

EntityFramework.Tools

.NET Command Line tools for Entity Framework Core
PowerShell
25
star
86

vsweb-docs

Showcase for Visual Studio web features
JavaScript
24
star
87

AzureIntegration

[Archived] Features that integrate ASP.NET Core with Azure. Project moved to https://github.com/aspnet/AspNetCore
C#
24
star
88

RazorTooling

Razor tooling for Visual Studio 2015
C#
23
star
89

PlatformAbstractions

OBSOLETE - used only for 1.0/1.1 patch builds
23
star
90

SignalR-Client-Java

OBSOLETE - see readme
23
star
91

libuv-build

Libuv build automation for ASP.NET Core
PowerShell
22
star
92

Wave

Cross-platform tools for running perf and stress tests
JavaScript
21
star
93

ServerTests

[Archived] Tests for Helios, WebListener and Kestrel. Project moved to https://github.com/aspnet/AspNetCore
C#
21
star
94

SignalR-ServiceBus

OBSOLETE - see readme
C#
21
star
95

libuv-package

NuGet packages for libuv
PowerShell
19
star
96

AADIntegration

[Archived] UI and library components for integrating ASP.NET Core applications with Azure Active Directory. Project moved to https://github.com/aspnet/AspNetCore
C#
19
star
97

BrowserLink

Browser Link loader for Visual Studio integration
C#
17
star
98

AspNetWebOptimization

ASP.NET Web Optimization for ASP.NET 4.x applications
C#
15
star
99

JitBench

Repo for testing JIT stuff
C#
15
star
100

aspnet-win-docker

Windows Docker image for ASP.NET Core [WIP]
PowerShell
15
star