I am searching for understanding the concept of DefaultHttpContext in deep. can any one explain it to me in simple? Thanks a lot
there is a sample code below:
var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[] {
new Claim(ClaimTypes.NameIdentifier, "E59899E9-AAFD-4AA6-B32E-12A27A4FA43D"),
new Claim(ClaimTypes.Name, "[email protected]")
// other required and custom claims
}, "TestAuthentication"));
var httpContext = new DefaultHttpContext()
{
User = user
};
/// passed a ControllerContext which defines the controller to be created
controllerContext = new Microsoft.AspNetCore.Mvc.ControllerContext()
{
HttpContext = httpContext,
};
CodePudding user response:
What is DefaultHttpContext
The DefaultHttpContext
class is the default implementation of the abstract HttpContext
class that is included in ASP.NET Core.
What is the concept of 'DefaultHttpContext' in Asp .net core?
HttpContext Initializes
a new instance of the DefaultHttpContext
class. "When an HTTP request arrives at the server, the server processes the request and builds an HttpContext object. This object represents the request which your application code can use to create the response"
Note: You can have a look more at official document here