asp.net-coreasp.net-core-7.0

ASP.NET Core 7 IResults usage


Please I'd like to know why I can't use the namespace Microsoft.AspNetCore.Http.HttpResults, but I can use Microsoft.AspNetCore.Http.Results namespace has the Results class which gives us different IResult implementations.

I noticed the constructors for Microsoft.AspNetCore.Http.HttpResults aren't in the doc. Are they private constructors? Please a dices explanation on this will help.

I have tried using Microsoft.AspNetCore.Http.HttpResults but keeps saying classes constructors have 0 parameters


Solution

  • The Microsoft.AspNetCore.Http.HttpResults is a namespace which contains classes that implement the IResult interface, so it will not contain any constructors.

    The IResult interface defines a contract that represents the result of an HTTP endpoint.

    The static Results(Microsoft.AspNetCore.Http.Results) class is used to create varying IResult objects that represent different types of responses.