How to use View components in Visual Studio 17.5.0 with .NET 7.0.200 in Linux

Andrus 121 Reputation points
2023-02-22T22:49:53.8066667+00:00
ASP .NET 7 MVC core application uses view commponents in Razor Views like in _Layout.chtml


    <vc:producttree roott="ProductTreeRoot">
    </vc:producttree>

After upgrading Visual Studio from 17.4.5 to 17.5.0 and deploying application to Linux
view components are no more rendered. Markup in browser contains same <vc:producttree> element.
If application in running from VS IDE in windows, markup contains proper html.


If Visual Studio is reverted back to 17.4.5 and older net runtime in forced in global.js using

     {   "sdk": {
         "version": "7.0.103",
         "rollForward": "disable"   }
     }

view components are rendered in Linux also.
How to use views components in with .NET 7.0.200 and Visual Studio 17.5.0 ?
Developer technologies | ASP.NET | ASP.NET Core
Developer technologies | .NET | Other
Developer technologies | Visual Studio | Other
Developer technologies | ASP.NET | Other
0 comments No comments
{count} votes

Accepted answer
  1. Xinran Shen - MSFT 2,091 Reputation points
    2023-02-23T02:39:51.0366667+00:00

    Hi @Andrus,

    This is a known issue that occurs in .Net 7.0.200 and Visual Studio 17.5.0, If you don't want to use older net runtime, you can use:

    @await Component.InvokeAsync("xxxx")
    

    to render view component.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,

    Xinran Shen

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.