Developer forum

Forum » Development » Finding IContext / IRequest

Finding IContext / IRequest

Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi there,

Upgrading a site to 9.10, I am trying to replace this code:

li.RetrievePDF(System.Web.HttpContext.Current.Response, System.Web.HttpContext.Current.Response);

What are the new equivalents of this? The release notes say this is going to be an easy (yay) but don't tell me how to fix it (bleh). I know I need IRequest and IResponse but don't know where to get them from. I found an old post that talks about Dynamicweb.Environment and Common.Context.Request but I can't find that anywhere in my upgraded project. Am I missing a package or assembly reference?

Thanks!


Replies

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply
This post has been marked as an answer

Hi Imar,

You're on the right track with Dynamicweb.Environment. Both interfaces are located in that package. The new 1.10 package of Ecommerce -- where the base live integration addin lives -- references Dynamicweb.Environment.4.0.1, which is available on NuGet.

To call the method, you can pass in Dynamicweb.Context.Current.Request and Dynamicweb.Context.Current.Response in production. Dynamicweb will wrap the HttpContext automatically. By the way, you can also make your own classes implementing the IRequest and IResponse interfaces for unit testing, or if you want to wrap the HttpContext yourself.

I hope that helps.

- Jeppe

Votes for this answer: 1
 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Thanks Jeppe, Dynamicweb.Context.Current.Request it was. Guess it moved out of Common into the root Dynamicweb namespace some time ago.

Imar

 

You must be logged in to post in the forum