Valums File Uploader - Including ValidateAntiForgeryToken

前端 未结 2 1249
失恋的感觉
失恋的感觉 2021-01-26 04:42

I\'m trying to protect my upload controller method using the MVC ValidateAntiForgeryToken but I\'m struggling to work out how to get the __RequestVerification

2条回答
  •  情书的邮戳
    2021-01-26 05:00

    I am using version 5.11.10 of FineUploader (rename of Valum's FileUploader FineUploader history mentioned) and it does contain the feature to specify a form, see Form Options

    An example of a FineUpload with AntiForgeryToken validation if your form doesn't contain any other form values is to include a form with some id (testForm in below example) with the AntiForgeryToken.

    @using (Html.BeginForm(MVCHelpers.Bank.Transactions.UploadFile(), FormMethod.Post, new { id = "testForm" }))
    {
        @Html.AntiForgeryToken()
    }
    

    And in the FineUploader specify the form it has to send also:

    This enables you to upload files in combination with [ValidateAntiForgeryToken] on your Action. You can also specify a real form if the upload is part of other form values, by specifying the id of that form. Pay attention to the autoUpload true since it's false by default when you set a form element.

提交回复
热议问题