Back to Devexpress

FileUploadStartEventArgs.RequestData Property

blazor-devexpress-dot-blazor-dot-fileuploadstarteventargs-df37ca74.md

latest2.5 KB
Original Source

FileUploadStartEventArgs.RequestData Property

Specifies the upload request’s custom data.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
public Dictionary<string, object> RequestData { get; set; }

Property Value

TypeDescription
Dictionary<String, Object>

A dictionary that contains the request’s custom data.

|

Remarks

Handle the FileUploadStart event to control file upload before it is started. Use the event argument’s RequestHeaders and RequestData properties to specify headers and custom data for the upload request.

The following snippet adds an authentication token and username to the request and gets their values in the server-side controller.

razor
<DxUpload Name="myFile" UploadUrl="https://localhost:10000/api/Upload/Upload/" 
          FileUploadStart="@OnFileUploadStart">
</DxUpload>

@code {
    void OnFileUploadStart(FileUploadStartEventArgs e) {
        e.RequestHeaders.Add("AuthHeader", "MySecretToken");
        e.RequestData.Add("Username", "MyUsername");
    }
}
csharp
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

[Route("api/[controller]")]
public class UploadController : ControllerBase {
    private readonly IWebHostEnvironment _hostingEnvironment;

    public UploadController(IWebHostEnvironment hostingEnvironment) {
        _hostingEnvironment = hostingEnvironment;
    }

    [HttpPost]
    [Route("UploadFile")]
    public ActionResult UploadFile(IFormFile myFile) {

        string authToken = Request.Headers["AuthHeader"];
        string username = Request.Form["Username"];
        // Implement validation and authentication here.
        // ...
    }
}

See Also

FileUploadStartEventArgs Class

FileUploadStartEventArgs Members

DevExpress.Blazor Namespace