dotnet / dotnet/aspnetcore

In .NET 8 / 9 ASP.NET Razor Class Library (RCL) views that use "partial" tag helper won't render nested views when referenced from ASP.NET Razor Pages app

Open
#55,710 0 comments 0 reactions 0 assignees View on GitHub
area-mvc
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Describe the bug

I already reported this in #51364 but was asked to do so again as it was logged into a branch that is not being worked on anymore. Hopefully this time it will get attention and hopefully be addressed.

When referencing Razor Class Library (RCL) Partial View from ASP.NET Razor Pages app, nested views of RCL are not being rendered when using `` tag helper, but will render just fine when using `await Html.PartialAsync(...)`

Here is the screenshot that shows the behavior of the test solution that is attached to this issue:
![image](https://github.com/dotnet/aspnetcore/assets/10164386/56bb712d-2a97-4cce-b45b-0ad7862af477)

In short, following code:

```

This is RCL's Primary Partial rendering nested partial using TagHelper

@await Html.PartialAsync("_NestedPartial")

```
and this one:

```

This is RCL Primary Partial rendering nested partial using TagHelper

```
**behave differently**, when to the best of my understanding they should not. In fact, they behave same way when used directly in Razor Pages web application.

### Expected Behavior

According to the documentation (https://learn.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/built-in/partial-tag-helper?view=aspnetcore-8.0) the Partial Tag Helper `` and the HTML Helper options for rendering a partial view `@await Html.PartialAsync` should behave the same.

### Steps To Reproduce

Use following sample solution to see the behavior:
[Razor Class Library Bug.zip](https://github.com/dotnet/aspnetcore/files/15309635/Razor.Class.Library.Bug.zip)

### Exceptions (if any)

_No response_

### .NET Version

9.0.100-preview.3.24204.13

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.