# Understanding RequestModelAccessor.RequestModel.SearchQuery.Clone()

**URL:** <https://forum.litium.com/t/understanding-requestmodelaccessor-requestmodel-searchquery-clone/587>\
**Category:** Questions\
**Tags:** litium-7\
**Created:** [February 13, 2019, 10:36am UTC](https://forum.litium.com/t/understanding-requestmodelaccessor-requestmodel-searchquery-clone/587 "2019-02-13T10:36:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![victaxel](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/victaxel/32/159_2.png) [@victaxel](https://forum.litium.com/u/victaxel)\
**Post date:** [February 13, 2019, 10:36am UTC](https://forum.litium.com/t/understanding-requestmodelaccessor-requestmodel-searchquery-clone/587/1 "2019-02-13T10:36:33Z")

</div>

Hello,

**The problem**  
I am building a react component with a few drop down fields. Each onChange of a dropdown calls the server which in turn calls an external api for information which populates the next dropdown. Each of the server calls are HttpPost.

Now, when the last dropdown changes, I receive article numbers of the products which should be displayed as search results. For this, I planned to use SearchResultViewModelBuilder.Build() which would build my product objects and return a SearchResultViewModel for me to return to my view.

However, when Build() runs, it tries to get a SearchQuery by calling \_requestModelAccessor.RequestModel.SearchQuery.Clone() and this throws a nullreferenceexception because RequestModel is null. The RequestModel object is disposed in RequestModelHandler when the page is finished loading, and I cannot use it to build my request. If I comment out the row in RequestModelHandler where RequestModel = null, I can successfully build the request.

**The question**  
Can I somehow keep the RequestModel object from disposing until after I have finished user input?

Litium version: 7.1

---

<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:** [February 13, 2019, 12:44pm UTC](https://forum.litium.com/t/understanding-requestmodelaccessor-requestmodel-searchquery-clone/587/2 "2019-02-13T12:44:08Z")

</div>

You need to add the client context on the request if that not already is there (some information about the context can be found in this thread [Moving ClientContext to external call](https://forum.litium.com/t/moving-clientcontext-to-external-call/340)). You also need to ensure that you are building all the data that you are returning before you return result as an `IHttpActionResult`. If you return an object that not is populated like an `IEnumerable<T>` that will be populated when it is executed you are out to have trouble and should change them to be populated inside the execution block (example adding `.ToList()` of them so they are populated directly).
