How to share classes/records with `Microsoft.AspNetCore.Mvc.FromQuery` attribute across .NET MAUI client and ASP .NET server projects?
01:43 30 Dec 2025

The following class:

public abstract record TasksTransactions
{

  public abstract record RetrievingOfSelection
  {
    
    public const string URN_PATH = "/api/tasks/selection";

    public record QueryParameters
    {
      
      public ForcedFiltering? forcedFiltering { get; set; }
      
      public record ForcedFiltering
      {

        [Microsoft.AspNetCore.Mvc.FromQuery(Name = "ff.s")]
        public required TaskGateway.SelectionRetrieving.RequestParameters.ForcedFiltering.ProgressStatues progressStatus { get; set; }
        
      }
      
      public OptionalFiltering? optionalFiltering { get; set; }
      
      public record OptionalFiltering
      {
        
        [Microsoft.AspNetCore.Mvc.FromQuery(Name = "of.sd")]
        public DateOnly? startingDate { get; set; }
        
        [Microsoft.AspNetCore.Mvc.FromQuery(Name = "of.ed")]
        public DateOnly? endingDate { get; set; }
        
        [Microsoft.AspNetCore.Mvc.FromQuery(Name = "of.sr")]
        public string? searchingByFullOrPartialTitleOrDescription { get; set; }
      }
            
    }

  }

}

is in C# project (let us call it "Shared") with following .csproj file:



  
    net9.0
    enable
    enable
  

  
    
  


Above class must be accessible from both of the following projects:

  1. .NET MAUI client

  2. AST .NET backend

I will append the .csproj files of both of them in the end of the question.

Currently, Microsoft.AspNetCore is not accessible from "Shared" project:

Cannot resolve symbol 'AspNetCore'

but if temporary comment out all usages of `Microsoft.AspNetCore`, my application will work.

Installing Microsoft.AspNetCore.Mvc to "Shared" project:



  
    net9.0
    enable
    enable
  

  
    
  

  
    
  


Now, Microsoft.AspNetCore is accessible from "Shared" project, but if try to build the solution, it will fail with:

Severity Code Description Project File Line Suppression State Details

Error (active) CS0234

The type or namespace name 'ApplicationPartAttribute' does not exist in the namespace 'Microsoft.AspNetCore.Mvc.ApplicationParts' (are you missing an assembly reference?) Client (net9.0-ios) D:\XXX\Implementation\Elements\Client\obj\Debug\net9.0-ios\iossimulator-x64\Client.MvcApplicationPartsAssemblyInfo.cs 14

enter image description here

It to uninstall Microsoft.AspNetCore and temporary comment out all usages of Microsoft.AspNetCore, solution will be built without errors again. How to fix it?

Appendix

.csproj File of Client Project

Mainly been generated by Visual studio for .NET MAUI + Blazor hybrid application.



  
    net9.0-maccatalyst;net9.0-ios;net9.0-android
    $(TargetFrameworks);net9.0-windows10.0.19041.0
    
    
    Exe
    Client
    true
    true
    enable
    false
    enable

    
    Client

    
    com.companyname.client
    2302D388-EFAC-4FCF-A8B6-3100441C5C7E

    
    1.0
    1

    14.2
    14.0
    24.0
    10.0.17763.0
    10.0.17763.0
    6.5

    
    false

  

  
    
    

    
    

    
    
    

    
    

    
    
  

  
    
    
    
    
    
  

  
    
    
    
    
    
    
    
  


.csproj File of Server Project

Mainly been generated by Visual studio for ASP .NET server application.



  
    net9.0
    enable
    enable
    ae619771-2592-4d7a-82ae-f1c264e1968e
    Linux
    ..\..\..
  

  
    
    
  

  
    
    
    
    
  


c# asp.net .net asp.net-core