# NullReferenceException for OrderConfirmation

**URL:** <https://forum.litium.com/t/nullreferenceexception-for-orderconfirmation/917>\
**Category:** Questions\
**Created:** [June 11, 2019, 6:38pm UTC](https://forum.litium.com/t/nullreferenceexception-for-orderconfirmation/917 "2019-06-11T18:38:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonas.olsson](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/jonas.olsson/32/177_2.png) [@jonas.olsson](https://forum.litium.com/u/jonas.olsson)\
**Post date:** [June 11, 2019, 6:38pm UTC](https://forum.litium.com/t/nullreferenceexception-for-orderconfirmation/917/1 "2019-06-11T18:38:51Z")

</div>

We have a problem when trying to send order confirmation email in Litium 7 Accelerator Mvc. We get a NullReferenceException in `MailServiceImpl.cs` on row 81

```
var page = pageMail.Page;
var pageUrl = _urlService.GetUrl(page, new PageUrlArgs(pageMail.ChannelSystemId) { AbsoluteUrl = true });

```

because this method in `OrderConfirmationEmail.cs` returns null

```
public override Page Page
{
    get
    {
        if (_page == null)
        {
            IoC.Resolve<PageByFieldTemplateCache<OrderConfirmationPageByFieldTemplateCache>>().TryFindPage(orderConfirmation =>
            {
                _page = orderConfirmation;
                return true;
            });
        }

        return _page;
    }
}

```

It seems page is not found in cache. Any ideas why? The order confirmation page is published and active on the channel.

Litium version: 7.1.0

---

<div class="post-metadata">

**Author:** ![steve.redstorm](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/steve.redstorm/32/14_2.png) [@steve.redstorm](https://forum.litium.com/u/steve.redstorm)\
**Post date:** [June 12, 2019, 8:14am UTC](https://forum.litium.com/t/nullreferenceexception-for-orderconfirmation/917/2 "2019-06-12T08:14:44Z")

</div>

Take a look at this link:

> [@Missing/nulled links after removing one website](https://forum.litium.com/t/missing-nulled-links-after-removing-one-website/903/2):
>
> Hi, The selection of page pointers has been changed in 7.1 so it is context based instead of channel based. If you upgrade it from 7.0 it is possible that the channel ids have been removed from the page pointers. Order carrier has also channel id. Change the return row as follows. return \_urlService.GetUrl(\_pageService.Get(pointerPage.EntitySystemId), new PageUrlArgs(pointerPage.ChannelSystemId != Guid.Empty ? pointerPage.ChannelSystemId : orderCarrier.ChannelID));

---

<div class="post-metadata">

**Author:** ![jonas.olsson](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/jonas.olsson/32/177_2.png) [@jonas.olsson](https://forum.litium.com/u/jonas.olsson)\
**Post date:** [June 12, 2019, 1:22pm UTC](https://forum.litium.com/t/nullreferenceexception-for-orderconfirmation/917/3 "2019-06-12T13:22:36Z")

</div>

Ok, but I still don’t understand how to solve it, I can’t change channel id in code. I dont have a problem in

```
public override string GetOrderConfirmationPageUrl(OrderCarrier orderCarrier)
{
    var website = _websiteService.Get(orderCarrier.WebSiteID);
    var pointerPage = website.Fields.GetValue<PointerPageItem>(AcceleratorWebsiteFieldNameConstants.OrderConfirmationPage);

    return _urlService.GetUrl(_pageService.Get(pointerPage.EntitySystemId), new PageUrlArgs(pointerPage.ChannelSystemId));
}

```

my problems occurs in

```
IoC.Resolve<PageByFieldTemplateCache<OrderConfirmationPageByFieldTemplateCache>>().TryFindPage(orderConfirmation =>
            {
                _page = orderConfirmation;
                return true;
            });

```

But maybe it is related. Do I need to update database somehow?

---

<div class="post-metadata">

**Author:** ![steve.redstorm](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/steve.redstorm/32/14_2.png) [@steve.redstorm](https://forum.litium.com/u/steve.redstorm)\
**Post date:** [June 12, 2019, 2:12pm UTC](https://forum.litium.com/t/nullreferenceexception-for-orderconfirmation/917/4 "2019-06-12T14:12:16Z")

</div>

No need for any changes in DB, check if visitors has right to see the page?

---

<div class="post-metadata">

**Author:** ![jonas.olsson](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/jonas.olsson/32/177_2.png) [@jonas.olsson](https://forum.litium.com/u/jonas.olsson)\
**Post date:** [June 12, 2019, 2:30pm UTC](https://forum.litium.com/t/nullreferenceexception-for-orderconfirmation/917/5 "2019-06-12T14:30:06Z")

</div>

Yes.  
Visitors has read access to order confirmation page.  
Page is published and active on swedish channel.  
We also get redirected to order confirmation page after purchase.

---

<div class="post-metadata">

**Author:** ![patric.forsgard](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/patric.forsgard/32/10_2.png) [@patric.forsgard](https://forum.litium.com/u/patric.forsgard)\
**Post date:** [June 12, 2019, 2:56pm UTC](https://forum.litium.com/t/nullreferenceexception-for-orderconfirmation/917/6 "2019-06-12T14:56:23Z")

</div>

The class `OrderConfirmationPageByFieldTemplateCache` is part of accelerator so that can be modified with your needs, after a quick check my feeling is that the cache only is working for web-requests, not background execution like sending mail.

Please, report a bug.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/litium/original/1X/12eddac3b8b661de1db86af10ac8151b571e6fb9.png) [@system](https://forum.litium.com/u/system)\
**Post date:** [July 10, 2019, 2:59pm UTC](https://forum.litium.com/t/nullreferenceexception-for-orderconfirmation/917/7 "2019-07-10T14:59:34Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
