Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Referencing Microsoft.AspNetCore.Blazor.Server disables server-side tag helpers #15757

Closed
SteveSandersonMS opened this issue Jul 27, 2018 · 5 comments
Assignees
Labels
area-blazor Includes: Blazor, Razor Components

Comments

@SteveSandersonMS
Copy link
Member

Repro:

  • Create a Blazor hosted or server-side app
  • In the server project, make it render a Razor page on the server (add AddMvc if not already present, then put Index.cshtml into a Pages directory)
  • Add @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers if you don't have it in _ViewImports.cshtml already
  • Observe that if you have syntax like <img src="~/blah.jpg" />, it does not resolve the ~ - it literally emits the URL ~/blah.jpg

I expect that Blazor's MSBuild targets are hijacking the server-side Razor compilation process, eliminating the normal server-side tag helpers, or something of that sort.

@danroth27
Copy link
Member

@Eilon

@floreseken
Copy link

Aha.. I had to remove the ~/ to make mine work also.. but I hadn't linked it to Blazor. Now it makes sense.

@Eilon
Copy link
Member

Eilon commented Jul 30, 2018

@SteveSandersonMS thanks for filing this!

@NTaylorMullen - FYI this is the bug I accidentally found on Friday.

@rynowak
Copy link
Member

rynowak commented Aug 20, 2018

There are two issues here:

  1. Our project templates should have a privateassets=all
  2. Our workaround for IsValidCompilation breaks Blazor aspnet/Razor#2482 is breaking tag helper discovery

We'll need to solve this by making sure that our ITagHelper workaround is referenced by client projects but not server projects.

rynowak referenced this issue in dotnet/blazor Aug 21, 2018
We recommend using this package with PrivateAssets=all everywhere to
make sure that the MSBuild files brought in by this package aren't
applied to transitively.

When that happens, the Blazor.Build MSBuild files will take over the
Razor functionality for other projects, which breaks MVC's view
compilation functionality.

This is part of a fix for #1216.
rynowak referenced this issue in dotnet/blazor Aug 22, 2018
We recommend using this package with PrivateAssets=all everywhere to
make sure that the MSBuild files brought in by this package aren't
applied to transitively.

When that happens, the Blazor.Build MSBuild files will take over the
Razor functionality for other projects, which breaks MVC's view
compilation functionality.

This is part of a fix for #1216.
@SteveSandersonMS
Copy link
Member Author

Done

SteveSandersonMS referenced this issue in SteveSandersonMS/BlazorMigration Nov 27, 2018
We recommend using this package with PrivateAssets=all everywhere to
make sure that the MSBuild files brought in by this package aren't
applied to transitively.

When that happens, the Blazor.Build MSBuild files will take over the
Razor functionality for other projects, which breaks MVC's view
compilation functionality.

This is part of a fix for #1216.
@mkArtakMSFT mkArtakMSFT transferred this issue from dotnet/blazor Oct 27, 2019
@mkArtakMSFT mkArtakMSFT added the area-blazor Includes: Blazor, Razor Components label Oct 27, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Dec 3, 2019
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
area-blazor Includes: Blazor, Razor Components
Projects
None yet
Development

No branches or pull requests

6 participants