When my web request is run, some properties that are in the Properties
property of HttpRequestMessage
are from the System.Web
namespace, although the application I am developing is .NET Core 2 Azure function.
I would like to use one object from the collection, MS_HttpContext
which is of type System.Web.HttpContextWrapper
. Is it possible to use this object and somehow cast to it? This object seems to be from standard .NET framework.
[FunctionName("Track")]
public static async Task<HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "track")]HttpRequestMessage req, TraceWriter log, ExecutionContext context)
{
// HttpContextWrapper is from System.Web, so this does not work
var ctx = (HttpContextWrapper)req.Properties["MS_HttpContext"]
}
EDIT: my question is slightly different than my previos question (Get remote IP address in Azure function), because it asks how can classes from System.Web
namespace be accessed from a .NET Core application. Although I admit the desired result is the same in both questions, to get the remote IP address.