我想基于Unity C#中的请求标头创建一个RegisterType
。
var container = new UnityContainer();
container.RegisterType<OrganizationServiceProxy>(new InjectionFactory(unityContainer =>
{
var request = HttpContext.Current.Request; //Exception 'Request is not available in this context
const string errorMessage = "Please add `CrmType` key to header to specify CRM type";
var crmTypeString = request.Headers["CrmType"];
.
.
.
return new SOmeObject(crmTypeString );
}));
但是发生了以下异常:
Request is not available in this context
如何通过Web访问Unity 5.2.0中的请求标头。