Construtor/Setter Injection using IoC in HttpHandler, is it possible?

后端 未结 2 760
一个人的身影
一个人的身影 2021-01-18 14:53

I\'ve ran into a rather hairy problem. There is probably a simple solution to this but I can\'t find it!

I have a custom HttpHandler that I want to process a request

2条回答
  •  旧时难觅i
    2021-01-18 15:33

    What you could do is have the HttpHandler call out to another object that actually handles the request. so in your HttpHandler's ProcessRequest method you would do something like this:

    public void ProcessRequest(HttpContext context)
    {
     var myHandlerObject = container.Resolve();
     myHandlerObject.ProcessRequest(context or some state/info that is required)
    }
    

提交回复
热议问题