0
votes

I am using kendo upload control to post file to server

@(Html.Kendo().Upload()
    .Name("file")
    .Async(a => a.Save("DocumentUpload", "Home")
    .AutoUpload(true))
    .Multiple(false))

    [HttpPost]
    public ActionResult DocumentUpload(IEnumerable<HttpPostedFileBase> files)
    {
          var isAjax = HttpContext.Request.IsAjaxRequest();
          // Why isAjax is false here ?? Is it not Ajax POST?
    }

I thought kendo makes ajax POST request. However this is not true, in asp.net HttpContext.Request.IsAjaxRequest() returns false.
When i check request headers i dont see X-Requested-With:XMLHttpRequest header as well.
Is this a bug in kendo upload?

Is there anyway to configure kendo upload control to make ajax POST?

1
I am in the same boat and wondering if you have come across any solution for this.YouKnowMe

1 Answers

0
votes

I believe it does use a POST by default.

I think your issue is that the name of your widget is file and your argument is files (plural).

Alternatively, you can set .Files("files") like this:

@(Html.Kendo().Upload()
    .Deferred()
    .Name("upload")
    .Multiple(true)
    .Async(async => async.AutoUpload(true)
        .SaveUrl(Url.Action("SaveAttachment"))
        .SaveField("files")))
    .Events(evt => evt.Success("refreshAttachments")))