Castle.Windsor and HttpContextWrapper

前端 未结 3 612
一整个雨季
一整个雨季 2021-01-16 02:16

HttpContextWrapper and HttpContextBase, as explained here, were introduced to make HttpContext more mockable/testable.

I\'m trying to use it with S#arp Architecture,

3条回答
  •  野的像风
    2021-01-16 02:48

    As others have stated - you are doing it wrong. My big question is:

    What are you doing that requires you to inject HttpContextBase in your controller? It might be more helpful to people wanting to help you if you would provide us more context about what you are really trying to do. Lets take Castle out of it and get down to what your controller is doing.

    BTW, your controller already has a reference to HttpContext. If you are doing this for testability, there is nothing you need to do at the controller level. You would just need to mock the HttpContextBase object as needed in your controller tests.

提交回复
热议问题