Both have Request and Response properties, but I can't write a method that takes either HttpContext or HttpContextBase. In some places either one or the other is available so I need to handle both. I know HttpContextWrapper can convert in one direction, but still... why is it like this?
+6
A:
HttpContext
has been around since .NET 1.0. Because of backward compatibility reasons, they can't change that class. HttpContextBase
was introduced in ASP.NET MVC to allow for better testability because it makes it easier to mock/stub it.
Sander Rijken
2009-12-29 09:30:09