I’m working on a web forms application which intends to be ported over to MVC for its vNext +1 release. But at the moment it’s a .NET 3.5 SP1 web forms application.
I’m wanting to have our own context which provides some helpers on top of the standard HttpContext/ HttpRequest/ HttpResponse/ etc objects. Also, I’m wanting to have decoupling of the HttpContext classes from the context.
Because there is the intention to go MVC I thought it’d be a good idea to make our custom context work with the HttpContextBase (and associated classes) which shipped in the System.Web.Abstractions assembly.
I don’t want to design a solution that solves some problems at the moment but needs to be re-written to achieve testability in MVC (and is just useless in MCV) but what I’ve achieved so far doesn’t really seem that useful.
The problem is I can’t find any good examples on how to achieve this, how to extend HttpContextWrapper, or HttpContextBase so that you can maintain seperation of concern.
You should not need to override the HttpContextWrapper or HttpContextBase to achieve this but instead have your custom context work with a HttpContextBase object, this way you will be able to test your custom context in isolation.
And when you create the custom context in the actual application just initialise using