From 55bc9eae5edb14b818c2fc99f5105e15f335d6e6 Mon Sep 17 00:00:00 2001 From: Dimo Dimov <961014+dimodi@users.noreply.github.com> Date: Fri, 21 Feb 2025 21:17:45 +0200 Subject: [PATCH 1/4] docs(Upload): Improve Upload controller documentation --- components/upload/events.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/upload/events.md b/components/upload/events.md index adc7bc597..55e106b07 100644 --- a/components/upload/events.md +++ b/components/upload/events.md @@ -783,6 +783,8 @@ var builder = WebApplication.CreateBuilder(args); // ... +builder.Services.AddControllers(); + var app = builder.Build(); // ... From fe4ca6dd988e7909c1dd05c2ca5a4d298cc5a170 Mon Sep 17 00:00:00 2001 From: Dimo Dimov <961014+dimodi@users.noreply.github.com> Date: Fri, 21 Feb 2025 21:25:35 +0200 Subject: [PATCH 2/4] Update Upload overview.md --- components/upload/overview.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/components/upload/overview.md b/components/upload/overview.md index 6f3ef8959..a92c96eb2 100644 --- a/components/upload/overview.md +++ b/components/upload/overview.md @@ -69,14 +69,17 @@ Steps 4 and 5 are optional, but strongly recommended. * The correct binding source attribute for the file name argument is `[FromForm]`. Set it explicitly if you are using an [`[ApiController]` attribute](https://learn.microsoft.com/en-gb/aspnet/core/web-api/). * Use the Upload [`OnRemove` event](slug:upload-events#onremove) to [send additional custom data with the file](slug:upload-events#send-custom-data-with-the-file) as an argument to the `Remove` controller method. -Both action methods must accept `POST` requests. Correct request routing depends on the application. +Both action methods must accept `POST` requests. -The `UploadController` class below assumes that the project name and namespace is `TelerikBlazorUpload`. +Request routing depends on the application and it outside the Upload component's scope. Normally, the following two statements in `Program.cs` are enough: -Make sure to enable controller routing in the app startup file (`Program.cs`). In this case, `app.MapDefaultControllerRoute();` is all that's needed. +* `builder.Services.AddControllers();` +* `app.MapDefaultControllerRoute();`. Also check the [Upload Troubleshooting](slug:upload-troubleshooting) page. +The `UploadController` class below assumes that the project name and namespace is `TelerikBlazorUpload`. + >caption Sample Upload Controller
From c7da313a469a16dc16dfe0fea076214c7091af6a Mon Sep 17 00:00:00 2001 From: Dimo Dimov <961014+dimodi@users.noreply.github.com> Date: Fri, 21 Feb 2025 21:27:32 +0200 Subject: [PATCH 3/4] Update components/upload/overview.md --- components/upload/overview.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/upload/overview.md b/components/upload/overview.md index a92c96eb2..ad23ef40d 100644 --- a/components/upload/overview.md +++ b/components/upload/overview.md @@ -71,7 +71,7 @@ Steps 4 and 5 are optional, but strongly recommended. Both action methods must accept `POST` requests. -Request routing depends on the application and it outside the Upload component's scope. Normally, the following two statements in `Program.cs` are enough: +Request routing depends on the application and it outside the Upload component's scope. Normally, the following two statements in the server project's `Program.cs` are enough: * `builder.Services.AddControllers();` * `app.MapDefaultControllerRoute();`. From 5b135b0f085f3df1ce838bcd52924ac200c4d19b Mon Sep 17 00:00:00 2001 From: Dimo Dimov <961014+dimodi@users.noreply.github.com> Date: Fri, 21 Feb 2025 21:35:04 +0200 Subject: [PATCH 4/4] Update troubleshooting.md --- components/upload/troubleshooting.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/components/upload/troubleshooting.md b/components/upload/troubleshooting.md index 0805727f7..2421f2873 100644 --- a/components/upload/troubleshooting.md +++ b/components/upload/troubleshooting.md @@ -26,7 +26,7 @@ The action method is hit, but the method argument is `null` ## HTTP 400 Bad request -The action method is not hit and the server returns HTTP 400 Bad request. +The action method is not hit and the server returns `HTTP 400 Bad request`. * Make sure that [controller routing is enabled and configured correctly](https://docs.microsoft.com/en-us/aspnet/core/mvc/controllers/routing). For example, the controller samples in this documentation use `[Route("api/[controller]/[action]")]`. It is enough to add `app.MapDefaultControllerRoute();` to `Program.cs` in the default Blazor project template. [Web API controllers require explicit `[Route]` configuration](https://learn.microsoft.com/en-gb/aspnet/core/web-api/?view=aspnetcore-8.0#attribute-routing-requirement). * Make sure that the `[Route]` attribute in the upload controller (if set) is compatible with `SaveUrl` and `RemoveUrl`. @@ -41,6 +41,16 @@ The Remove action may return `HTTP 415 Unsupported Media Type`. This means that the Remove action method expects `IEnumerable