Skip to content

docs(Upload): Improve Upload controller documentation #2782

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions components/upload/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,8 @@ var builder = WebApplication.CreateBuilder(args);

// ...

builder.Services.AddControllers();

var app = builder.Build();

// ...
Expand Down
9 changes: 6 additions & 3 deletions components/upload/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

<div class="skip-repl"></div>
Expand Down