Try our conversational search powered by Generative AI!

Accessing currentPage in controller called by JavaScript.


I'm calling this action in my controller:


public async Task<>ActionResult> ApplySearch(ProductSearchPage currentPage, QueryJsonObject jsonObject)
    //currentPage is always null.

It is called through this JavaScript:

    type: "POST",
    url: "@Url.Action("ApplySearch""Product/ProductSearch")"// the URL of the controller action method
    dataType: "json",
    contentType: "application/json; charset=utf-8",
    data: JSON.stringify(queryObject), // optional data
    success: function (result) {
    error : function(req, status, error) {

How do I pass along the page so that I can access it in my action?

Thank you!

Edited, Aug 11, 2017 11:34

The easiest way is to rely on the Episerver routing, and the in-built modelbinder (IMO laughing)


  • You have an instance of your ProductSearchPage content type created under the url /products/product-search.
  • Your ProductSearchPageController has the action ApplySearch method within it.

Make your javascript request to the url /products/product-search/ApplySearch - rather than rely on the default MVC routing of {controller}/{Action} which in this case would be ProductSearchPage/ApplySearch. Although both of these requests will be routed correctly, the currentPage object won't be bound as Episerver can't work out the context of the request, ie what content the request should be mapped to.

This appraoch assumes that you will always know the editorially controlled url of your ProductSearchPage, but you could easily get around that by having a content reference stored or 'locking' down the ability for editors to change the ProductSearchPage url.

Aug 11, 2017 13:29
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.