asp.net-corerazor-pages

How to access PageRemote attribute in class library


I use .NET 6 and I want to use [PageRemote] in class library, I installed Microsoft.AspNetCore.Mvc in my class library, but still I can't use [PageRemote] in my class library.

How can I use [PageRemote] in class libraries?


Solution

  • Try adding the ASP.NET Core framework reference into your class library as is shown here:

    https://learn.microsoft.com/en-us/aspnet/core/fundamentals/target-aspnetcore?view=aspnetcore-6.0&tabs=visual-studio#use-the-aspnet-core-shared-framework

    To reference ASP.NET Core, add the following <FrameworkReference> element to your project file:

    <Project Sdk="Microsoft.NET.Sdk">
    
       <PropertyGroup>
           <TargetFramework>netcoreapp3.1</TargetFramework>
       </PropertyGroup>
    
       <ItemGroup>
           <FrameworkReference Include="Microsoft.AspNetCore.App" />
       </ItemGroup>
    
    </Project>