Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Simon Dingley 1461 posts 3414 karma points c-trib
    Jul 25, 2016 @ 08:53
    Simon Dingley

    XPath AutoComplete Call to GetData uses GET instead of POST

    I have recently upgraded a site that I have previously inherited to Umbraco v6.2.5. One issue that has been raised is that the XPath Autocomplete feature has stopped working. I've been doing some digging and a null reference exception is being thrown because autoCompleteText returns null in the HttpContext.Current.Request.Form collection. The reason why is because the call to GetData in XPathAutoCompleteBase is using GET instead of the POST method.

    I dug a little deeper and stepped through some of the JS and found that the request is initiated with a POST as follows but it is somehow converted and I can see in the browser inspector that it is actually made as GET.

                minLength: minLength,
                source: function (request, response) {
                        type: 'POST',
                        data: { autoCompleteText: request.term, selectedItems: hidden.val() },
                        contentType: "application/x-www-form-urlencoded; charset=utf-8",
                        url: '/Base/' + xPathAutoCompleteId + '/GetData/' + dataTypeDefinitionId + '/' + currentId,
                        dataType: 'json',
                        success: function(data) {

    Has anyone come across this before or have any ideas how or why this might be getting converted?

    Thanks, Simon

  • Simon Dingley 1461 posts 3414 karma points c-trib
    Jul 25, 2016 @ 09:26
    Simon Dingley

    As usual after posting I think I can answer this myself as shortly after it triggered a thought process which I think has led me to identify the source of the issue.

    In case it is of help to others I believe the cause to be a rewrite rule for adding a trailing slash to all urls. It causes a redirect and subsequently loses the post data and results in a GET rather than POST.

    Here is the amended rule which now works around the issue:

    <rule name="AddTrailingSlashRule" stopProcessing="true">
        <match url="(.*[^/])$" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" pattern="(.*?)\.[a-zA-Z]{1,4}$" negate="true" />
            <add input="{REQUEST_URI}" pattern="^/[Bb]ase/(.*)" negate="true" />
        <action type="Redirect" url="{R:1}/" />

    Hopefully this might help someone else.

Please Sign in or register to post replies

Write your reply to: