This article is a mirror article of machine translation, please click here to jump to the original article.

View: 96|Reply: 0

[Communication] .NET/C# class libraries reference and use ASP.NET Core API methods

[Copy link]
Posted on 2/28/2026 9:53:17 PM | | |
Requirements: Create a new library project in .NET 8 (Sdk="Microsoft.NET.Sdk", this library is a help class, there will be many extension methods, such as web-related extensions, but you will find that it cannot be referenced, prompting that the reference cannot be found, how can you reference the methods in AspNetCore?

.NET Project SDK

SDKs available, available include:

ID
description
Repository
Microsoft.NET.Sdk.NET SDKhttps://github.com/dotnet/sdk
Microsoft.NET.Sdk.Web.NETWeb SDKhttps://github.com/dotnet/sdk
Microsoft.NET.Sdk.Razor.NETRazor SDKhttps://github.com/dotnet/aspnetcore
Microsoft.NET.Sdk.BlazorWebAssemblyThe .NETBlazor WebAssemblySDKhttps://github.com/dotnet/aspnetcore
Microsoft.NET.Sdk.Worker.NETWork Services SDKhttps://github.com/dotnet/aspnetcore
Aspire.AppHost.Sdk.NETAspire SDKhttps://github.com/dotnet/aspire
MSTest.SdkMSTest SDKhttps://github.com/microsoft/testfx

Option 1

Using the shared framework, the configuration is as follows:

The shared framework isA collection of assemblies included in the runtime, so there is no need to resolve them separately through NuGet。 You can think of it as a NuGet package, though, because they are handled very similarly. The main difference is that it doesn't need to be downloaded from NuGet because it's already included in the runtime environment.

Since it is distributed with the runtime environment, this means you cannot reference a specific version of it. Instead, you always get the version included in the available version of the runtime environment. The benefit of this is that when the runtime environment is updated, its contents are automatically updated, so applications that rely on shared frameworks are also automatically updated at runtime.

Option 2

Modify the SDK directly, and configure it as follows:

Reference:

The hyperlink login is visible.
The hyperlink login is visible.




Previous:The front-end page CSS implements the loading animation
Next:Front-end Performance Optimization: Ditch XMLHttpRequest in favor of fetch interfaces
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com