Owin:异常:System.ObjectDisposedException:无法访问已处置的对象。对象名称:“ System.Net.HttpListenerRequest”

时间:2018-07-25 06:10:53

标签: c# httprequest owin

我下面有很多下面的日志,有人知道这的根本原因吗?这是否与以下代码相关:

// Gets the client IP when hosted in IIS, where HttpContext.Current is not null.
if (httpRequest != null)
    return httpRequest.UserHostAddress;

// Gets the client IP when hosted in Owin, where there is no HttpContext.Current by default.
if (!request.Properties.ContainsKey("MS_OwinContext")) return null;

var context = request.Properties["MS_OwinContext"] as OwinContext;
return context?.Request.RemoteIpAddress;

日志:

异常:System.ObjectDisposedException:无法访问已处置的对象。 对象名称:“ System.Net.HttpListenerRequest”。在System.Net.HttpListenerRequest.CheckDisposed()在System.Net.HttpListenerRequest.get_RemoteEndPoint()在Microsoft.Owin.Host.HttpListener.RequestProcessing.OwinHttpListenerRequest.GetRemoteIpAddress()在Microsoft.Owin.Host.HttpListener.RequestProcessing.CallEnvironment.get_ServerRemoteIpAddress ()at Microsoft.Owin.Host.HttpListener.RequestProcessing.CallEnvironment.PropertiesTryGetValue(String key,Object&value)在Microsoft.Owin.Host.HttpListener.RequestProcessing.CallEnvironment.TryGetValue(String key,Object&value)在Microsoft.Owin.OwinRequest .Get [T](字符串键)

0 个答案:

没有答案