Developer forum

Forum » Development » Error when use Order.GetOrderByID

Error when use Order.GetOrderByID

George Nelzo Pereira
Reply
Hi people...
 
We have one Webservice (Generic Handler - .ashx) to get some informations...
the code is basic... I send the OrderID (in this case is one CART)
 
Dynamicweb.eCommerce.Orders.Order oOrder = (Dynamicweb.eCommerce.Orders.Order)Dynamicweb.eCommerce.Orders.Order.GetOrderByID(orderid);
 
_shippingFee = oOrder.ShippingFee.Price;
_orderamount = oOrder.TotalPrice;
 
https://georgenelzo.tinytake.com/sf/NTU3NTgyXzI4NjQ0MDI
 
After I made upgrade to 8.8.0.4 this information is returning error (NullReferenceException)
https://georgenelzo.tinytake.com/sf/NTU3NjE2XzI4NjQ1NjA
Before this version was working fine.
 
This can be a BUG or Is not possible anymore to access this informations when is a cart?

Replies

 
Nicolai Høeg Pedersen
Reply

What did you upgrade from. From the stack, it seems like something from 8.4.1.7 released almost 2 years ago.

The problem is, that total price is looking for a value based on the context of the request (i.e. currency and others). And all of that requires a session state which you do not have in a .ashx handler.

To solve the issue, you should change your .ashx so it implements System.Web.SessionState.IRequiresSessionState (it is just a marker interface, so no implementation is needed)

BR Nicolai

 
George Nelzo Pereira
Reply

Hi Nicolai thanks for your reply.

I was using 8.7.2.4 (was working fine)

With IRequiresSessionState I need be logged in /Admin (I tested here then work fine)

But I use this ashx in the FE with users without login to get some informations from the CART

 
Nicolai Høeg Pedersen
Reply

Why do you need to be logged into /admin with IRequiresSessionState?

I see no changes in the code related to the stack trace you have published. It looks at the orders total price, and to do that, it needs a context based on a session. You did not change anything at all in your code...?

NP

 
George Nelzo Pereira
Reply

Hi Nicolai.

I'm back to this error...

Well, I tried add the IRequiresSessionState, but when I do this always they are return this: <script>setTimeout('top.location = "/Admin/Access/Access_Logoff.aspx";', 1000);</script>
then If I make login in Admin then is work... strange because is not fire the ProcessRequest()

If I remove the IRequiresSessionState then is work until I use the updateCart()... after that I got the error (NullReferenceException) in oOrder.TotalPrice.

I create a simple ashx (standard from Visual Studio), is work the same... with IRequiresSessionState always send to logout, without is work...

 

 
Nicolai Høeg Pedersen
Reply

Well, that is because you are in a state/url location where login is required.

If you have placed it in /CustomModules/* or /Admin that is the case.

If you do not want login to be required, place it outside that folder.

 
George Nelzo Pereira
Reply

sad Thats true... 

Sorry.. I do that.

Thanks

 
Nicolai Høeg Pedersen
Reply

No problem smiley

 

You must be logged in to post in the forum