1

We're upgrading some of our projects from 8.2 to 10.1.

We have some global components that gets deployed into different Sitecore projects, those are in 8.2, 9.3 and 10.1.

We're trying to get those global components compatible with all versions, meaning we upgrade those after a new Sitecore version is released and then deployed to the different instances.

With 10.1, the changes to Sitecore.Pipelines.HttpRequest.HttpRequestArgs are not compatible with 8.2 anymore: basically the property Context got renamed to HttpContext, this was already marked as obsolete in the v9.1.

enter image description here

So my question is, how can I make this code working with both Sitecore versions? One of the options I'm thinking about is to use the System.Web.HttpContext instead, but I didn't deep into enough to check if this would work.

Any suggestion is welcome, Thanks!

1
  • are you using the same Sitecore visual studio solution for different versions of sitecore? Mar 24, 2021 at 9:46

1 Answer 1

2

The semantics of the code/(namespace) you are looking at is bound to HttpRequest processing concept.

It is completely legitimate to:

  1. Introduce a base class with protected virtual HttpContextBase HttpContext => new HttpContextWrapper(System.Web.HttpContext.Current) property
  2. Use that property in derived classes instead the breaking change you've discovered

The code would be based on stable/foundational ASP.NET API that would never change.

Secondly, code would be unit-testable.

Thirdly, it would override static HttpContext property so that it would not be abused.

Be mindful to use that only for request-related pipelines (no background ones please, f.e. job or publishing, or indexing).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.