AbleCommerce Forums
»
AbleCommerce
»
General Questions
»
Preferred way to access HttpContext from Plugin?
Rank: Advanced Member
Groups: Authorized User, Developers Joined: 5/30/2020(UTC) Posts: 125
Thanks: 14 times Was thanked: 3 time(s) in 3 post(s)
|
I want to make use of some data from our custom database in multiple widgets on the product page. I'd like to cache the results of our lookup in the HttpContext the first time the function is hit to avoid extra database lookups later in the page. If we are using Plugins to add our functionality, what is the preferred method to access the HttpContext? Is it still HttpContext.Current?
The reason I ask is that we have been doing .Net Core development and they were injecting IHttpContextAccessor, so I could access it from the constructor of my custom classes. Wasn't sure if AC was doing anything similar.
|
|
|
|
Rank: Advanced Member
Groups: Admin, Developers, Registered, HelpDesk, Authorized User Joined: 10/5/2018(UTC) Posts: 704
Thanks: 5 times Was thanked: 113 time(s) in 112 post(s)
|
Yes, you can use HttpContext.Current in plugins.
For example, if you have the source code, you can see our existing plugins implementations.
\IntegratedProviders\CanadaPost\CanadaPost.cs line: 483
|
|
|
|
AbleCommerce Forums
»
AbleCommerce
»
General Questions
»
Preferred way to access HttpContext from Plugin?
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The AbleCommerce Forums uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close