Back to Devexpress

UploadHttpRequestInfo Class

blazor-devexpress-dot-blazor-a83b6844.md

latest2.2 KB
Original Source

UploadHttpRequestInfo Class

Provides information about an HTTP request.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
public class UploadHttpRequestInfo

The following members return UploadHttpRequestInfo objects:

Remarks

The UploadFileInfo class instance is used for the FileUploadError event. This event occurs when a file could not be uploaded to the server.

razor
<DxUpload Name="myFile" UploadUrl="https://localhost:10000/api/Upload/UploadFile/"
          FileUploadError="@OnUploadError">
</DxUpload>
<div class="alert alert-danger @(ErrorVisible? " visible" : " invisible")">@MyError</div>

@code {
    bool ErrorVisible { get; set; } = false;
    string MyError { get; set; }

    void OnUploadError(FileUploadErrorEventArgs e) {
        MyError = e.RequestInfo.ResponseText;
        ErrorVisible = true;
        InvokeAsync(StateHasChanged);
    }
}
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) {
        // Check whether the file can be uploaded.
         // ...
         return BadRequest("An error occured during file upload.");
    }
}

Inheritance

Object UploadHttpRequestInfo

See Also

UploadHttpRequestInfo Members

DevExpress.Blazor Namespace