The page posts to the surface controller fine and the model posted is parsed correctly, but we can't access the CurrentPage model. We've tried several methods to get the CurrentPage but haven't found one that works. We're currently posting the uformpostroutevals with the form, but don't know how to force the CurrentPage to be set (the UmbracoContext.Current.PageId is null).
Is it possible to use an ajax post and still maintain the UmbracoContext.Current properties?
v6 Surface Controller ajax get CurrentPage
We're trying to get the CurrentPage in a Surface Controller in v6.1.5 when the Surface controller is posted via ajax (not from a begin form request).
our ajax call looks like this:
$.ajax({
url:"/umbraco/surface/searchresults/changepage",
type: "POST",
cache: false,
data: $(this).serialize(),
xhrFields: {
withCredentials: true
},
success: function (data) {
$(".productListings").empty().append(data);
}
});
The page posts to the surface controller fine and the model posted is parsed correctly, but we can't access the CurrentPage model.
We've tried several methods to get the CurrentPage but haven't found one that works. We're currently posting the uformpostroutevals with the form, but don't know how to force the CurrentPage to be set (the UmbracoContext.Current.PageId is null).
Is it possible to use an ajax post and still maintain the UmbracoContext.Current properties?
Did you try to use CurrentPage.Id in the SurfaceController?
I do with no trouble at all.
Our issue is with ajax posts. The CurrentPage object is null in ajax posts to the SurfaceController (at least for me).
In normal postback and non-ajax methods, the CurrentPage object is populated.
Hi I also have the same issue.
Is there a workaround when using ajax posts short of putting the page id in the request and resolving it using umbraco?
I believe we ended up passing the page id in with the ajax request and resolving it using the ApplicationContext
is working on a reply...