Skip to content

Help Blazor users correctly setup the Microsoft.AspNetCore.Components.Web using directive #9747

@danroth27

Description

@danroth27

A using directive for the Microsoft.AspNetCore.Components.Web namespace is required to get the web related Razor directives to work (like @onclick and friends). We add this using directive in our templates, but occasionally users still get tripped up by not having it. For example, I helped someone who was following the Blazor Hybrid tutorials for WPF & WinForms, but they messed up the name of their _Imports.razor file. The app compiled and ran but a bunch of the Razor directives didn't work. I've seen users also start with a Razor Class Library configured with Pages & View and then try to add Blazor components to it run into this problem.

Can we provide better diagnostics for this situation, where users have the web related Razor directives in their code, but they are missing the using directive?

Or could we add this using directive as an implicit using for the Razor SDK? Or maybe just the Web and Blazor WebAssembly SDKs?

Metadata

Metadata

Assignees

Labels

area-compilerUmbrella for all compiler issues

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions