I have this .NET Standard library where I want to write a .NET Core middleware.
Inside which I want to do :
Endpoint endpoint = httpContext.GetEndpoint()
I assume you're writing a middleware for ASP.NET Core 3.1 since you included the "asp.net-core-3.1" tag.
To use that extension, you need to target netcoreapp3.*
instead of netstandard2.*
:
<TargetFramework>netcoreapp3.1</TargetFramework>
(You can see which ASP.NET Core versions that extension is available for in the dropdown menu on the documentation page)
You will also need to either:
Microsoft.NET.Sdk.Web
MSBuild SDK:
<Project Sdk="Microsoft.NET.Sdk.Web">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
Reference: Use ASP.NET Core APIs in a class library