'What is the .net core version of HttpContext.Current.Request.ServerVariables["HTTP_HOST"]

I am trying to rewrite this line of code HttpContext.Current.Request.ServerVariables["HTTP_HOST"] it cant find current it doesn't contain a definition.



Solution 1:[1]

There is an extension in .net core. To use it you need to install prerequested package which denoted below.

https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.http.httpcontextservervariableextensions.getservervariable?view=aspnetcore-5.0

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ulas