我正在编写web-api 2 OWIN-selfhosted控制台应用程序(我有一个带有ApiControllers的dll库和一个带有DataAccess类型的dll)。我已经添加了web-api跟踪。
public class dobStartUp
{
public void Configuration(IAppBuilder app)
{
var config = new HttpConfiguration();
config.Services.Replace(typeof(IAssembliesResolver),new dobAssembliesResolver());
var container = new UnityContainer();
container.RegisterType<IdobRDBRepository, dobRDBRepository>(new TransientLifetimeManager());
container.RegisterType<IResourcesContentRepository, AS3ContentRepository>(new TransientLifetimeManager());
config.EnableSystemDiagnosticsTracing();
SystemDiagnosticsTraceWriter traceWriter = config.EnableSystemDiagnosticsTracing();
traceWriter.IsVerbose = false;
traceWriter.MinimumLevel = TraceLevel.Info;
config.DependencyResolver = new UnityDependencyResolver(container);
config.MapHttpAttributeRoutes();
app.UseWebApi(config);
}
}
class Program
{
static void Main(string[] args)
{
string baseAdress = "http://localhost:9001/";
using(Microsoft.Owin.Hosting.WebApp.Start<dobStartUp>(url: baseAdress))
{
Console.WriteLine("Owin web-app host started");
Console.Read();
}
}
}
当我尝试通过浏览器或客户端(VLC播放器或WinAmp)调用我的服务以获得流内容时 - 一切正常。但是当我查看跟踪记录时,我发现每个跟踪记录都会发生两次。
dobiji.WebApi.SimpleHost.vshost.exe Information: 0 : Request, Method=GET, Url=http://localhost:9001/resources/buf/2, Message='http://localhost:9001/resources/buf/2'
dobiji.WebApi.SimpleHost.vshost.exe Information: 0 : Request, Method=GET, Url=http://localhost:9001/resources/buf/2, Message='http://localhost:9001/resources/buf/2'
dobiji.WebApi.SimpleHost.vshost.exe Information: 0 : Message='Resources', Operation=DefaultHttpControllerSelector.SelectController
dobiji.WebApi.SimpleHost.vshost.exe Information: 0 : Message='Resources', Operation=DefaultHttpControllerSelector.SelectController
'dobiji.WebApi.SimpleHost.vshost.exe' (CLR v4.0.30319: dobiji.WebApi.SimpleHost.vshost.exe): Loaded 'D:\Projects\dobiji\sources\v2\dobiji.WebApi.SimpleHost\bin\Release\MySql.Data.Entity.EF6.dll'. Cannot find or open the PDB file.
'dobiji.WebApi.SimpleHost.vshost.exe' (CLR v4.0.30319: dobiji.WebApi.SimpleHost.vshost.exe): Loaded 'C:\Windows\assembly\GAC_MSIL\MySql.Data\6.8.3.0__c5687fc88969c44d\MySql.Data.dll'. Cannot find or open the PDB file.
dobiji.WebApi.SimpleHost.vshost.exe Information: 0 : Message='dobiji.WebApi.ResourcesController', Operation=DefaultHttpControllerActivator.Create
dobiji.WebApi.SimpleHost.vshost.exe Information: 0 : Message='dobiji.WebApi.ResourcesController', Operation=DefaultHttpControllerActivator.Create
dobiji.WebApi.SimpleHost.vshost.exe Information: 0 : Message='dobiji.WebApi.ResourcesController', Operation=HttpControllerDescriptor.CreateController
dobiji.WebApi.SimpleHost.vshost.exe Information: 0 : Message='dobiji.WebApi.ResourcesController', Operation=HttpControllerDescriptor.CreateController
dobiji.WebApi.SimpleHost.vshost.exe Information: 0 : Message='Selected action 'GetResourceById_buffered(Int32 id)'', Operation=ApiControllerActionSelector.SelectAction
dobiji.WebApi.SimpleHost.vshost.exe Information: 0 : Message='Selected action 'GetResourceById_buffered(Int32 id)'', Operation=ApiControllerActionSelector.SelectAction
dobiji.WebApi.SimpleHost.vshost.exe Information: 0 : Message='Parameter 'id' bound to the value '2'', Operation=ModelBinderParameterBinding.ExecuteBindingAsync
dobiji.WebApi.SimpleHost.vshost.exe Information: 0 : Message='Parameter 'id' bound to the value '2'', Operation=ModelBinderParameterBinding.ExecuteBindingAsync
现在我只有2个带有多种方法的ApiControllers。从客户端跟踪的每个方法都是相同的方式 - 公开跟踪记录。 我还没有找到任何多重注册&#34;在我的代码中。它可能是什么原因?