Upload Component report HTTP 405 error #1694

Closed
opened 2026-01-29 17:57:23 +00:00 by claunia · 2 comments
Owner

Originally created by @geextudio on GitHub (Mar 30, 2025).

Describe the bug
Upload Component report HTTP 405 error (Method not allowed) after choosing a file.

To Reproduce
Steps to reproduce the behavior:

  1. I add an upload component as the demo code from the official site of Radzen blazor in my razor page as following:
@rendermode InteractiveServer

<RadzenContent Container="main">
    <RadzenCard Variant="Variant.Outlined">
        <RadzenText TextStyle="TextStyle.Subtitle2" TagName="TagName.H3">Single file upload</RadzenText>
        <RadzenUpload Url="upload/single" Accept=".txt,.sql" 
            Progress=@(args => OnProgress(args, "Single file upload")) 
            Style="width: 100%"
            InputAttributes="@(new Dictionary<string, object>() { { "aria-label", "select file" } })">
        </RadzenUpload>
    </RadzenCard>
</RadzenContent>
<EventConsole @ref=@console />

@code {
    EventConsole console;
    void OnProgress(UploadProgressArgs args, string name)
    {
        console.Log($"{args.Progress}% '{name}' / {args.Loaded} of {args.Total} bytes.");

        if (args.Progress == 100)
        {
            foreach (var file in args.Files)
            {
                console.Log($"Uploaded: {file.Name} / {file.Size} bytes");
            }
        }
    }

    void OnComplete(UploadCompleteEventArgs args)
    {
        console.Log($"Server response: {args.RawResponse}");
    }
}

  1. Click 'Choose' button;
  2. Check the developer tool of browser
  3. Get the error of HTTP 405

Expected behavior
The file I choose can be uploaded correctly without HTTP 405

Screenshots
Image

Desktop (please complete the following information):

  • OS: macOS
  • Browser: Microsoft Edge
Originally created by @geextudio on GitHub (Mar 30, 2025). <!-- IMPORTANT: Read this first!!! 1. If you own a Radzen Professional or Еnterprise subscription you can report your issue or ask us a question via email at info@radzen.com. Radzen staff will reply within 24 hours (Professional) or 16 hours (Enterprise) 2. The Radzen staff guarantees a response to issues in this repo only to paid subscribers. 3. If you have a HOW TO question start a new forum thread in the Radzen Community forum: https://forum.radzen.com. Radzen staff will close issues that are HOWTO questions. 4. Please adhere to the issue template. Specify all the steps required to reproduce the issue or link a project which reproduces it easily (without requiring extra steps such as restoring a database). --> **Describe the bug** Upload Component report HTTP 405 error (Method not allowed) after choosing a file. **To Reproduce** Steps to reproduce the behavior: 1. I add an upload component as the demo code from the official site of Radzen blazor in my razor page as following: ```razor @rendermode InteractiveServer <RadzenContent Container="main"> <RadzenCard Variant="Variant.Outlined"> <RadzenText TextStyle="TextStyle.Subtitle2" TagName="TagName.H3">Single file upload</RadzenText> <RadzenUpload Url="upload/single" Accept=".txt,.sql" Progress=@(args => OnProgress(args, "Single file upload")) Style="width: 100%" InputAttributes="@(new Dictionary<string, object>() { { "aria-label", "select file" } })"> </RadzenUpload> </RadzenCard> </RadzenContent> <EventConsole @ref=@console /> @code { EventConsole console; void OnProgress(UploadProgressArgs args, string name) { console.Log($"{args.Progress}% '{name}' / {args.Loaded} of {args.Total} bytes."); if (args.Progress == 100) { foreach (var file in args.Files) { console.Log($"Uploaded: {file.Name} / {file.Size} bytes"); } } } void OnComplete(UploadCompleteEventArgs args) { console.Log($"Server response: {args.RawResponse}"); } } ``` 2. Click 'Choose' button; 3. Check the developer tool of browser 4. Get the error of HTTP 405 **Expected behavior** The file I choose can be uploaded correctly without HTTP 405 **Screenshots** <img width="667" alt="Image" src="https://github.com/user-attachments/assets/71b05608-9fa3-4f00-9444-fb837a08c594" /> **Desktop (please complete the following information):** - OS: macOS - Browser: Microsoft Edge
Author
Owner

@enchev commented on GitHub (Mar 31, 2025):

You need UploadController that will handle the specified Url. Check our demos for reference.

@enchev commented on GitHub (Mar 31, 2025): You need UploadController that will handle the specified Url. Check our demos for reference.
Author
Owner

@geextudio commented on GitHub (Mar 31, 2025):

You need UploadController that will handle the specified Url. Check our demos for reference.

I added the controller as bellow

app.MapPost("/upload/single", (IFormFile file) =>
{
    try
    {
        return Results.Ok();
    }
    catch (Exception ex)
    {
        return Results.InternalServerError(ex.Message);
    }
})

get http error 400

Image

@enchev

@geextudio commented on GitHub (Mar 31, 2025): > You need UploadController that will handle the specified Url. Check our demos for reference. I added the controller as bellow ```C# app.MapPost("/upload/single", (IFormFile file) => { try { return Results.Ok(); } catch (Exception ex) { return Results.InternalServerError(ex.Message); } }) ``` get http error 400 <img width="436" alt="Image" src="https://github.com/user-attachments/assets/566e5e7a-04b6-4839-b902-f82a05133c3a" /> @enchev
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#1694