C
C#14mo ago
SwaggerLife

❔ RequestSizeLimit on Actions not Working!

I have an action that is uploading a large file. The file size is 189mb. For some reason I'm getting this error 413 Error: Request Entity Too Large. I even tried adding the RequestSizeLimit attribute on top of the action but it still has no effect. Here is the action
[RequestSizeLimit(int.MaxValue)]
[HttpPost]
[Authorize]
[SwaggerOperation("An action for creating an episode.")]
public async Task<IActionResult> CreateEpisodeAsync([FromForm] CreateEpisodeRequest request,
CancellationToken cancellationToken = default)
{
var result = await _mutationService.CreateEpisodeAsync(request, cancellationToken);
var response = result.ToApiResponse();

if (result.IsSuccessful)
response.StatusCode = HttpStatusCode.Created;
else
response.StatusCode = result.ErrorCode switch
{
ErrorCode.NotFound => HttpStatusCode.NotFound,
ErrorCode.InternalServerError => HttpStatusCode.InternalServerError,
_ => HttpStatusCode.BadRequest
};

return response.ToActionResult();
}
[RequestSizeLimit(int.MaxValue)]
[HttpPost]
[Authorize]
[SwaggerOperation("An action for creating an episode.")]
public async Task<IActionResult> CreateEpisodeAsync([FromForm] CreateEpisodeRequest request,
CancellationToken cancellationToken = default)
{
var result = await _mutationService.CreateEpisodeAsync(request, cancellationToken);
var response = result.ToApiResponse();

if (result.IsSuccessful)
response.StatusCode = HttpStatusCode.Created;
else
response.StatusCode = result.ErrorCode switch
{
ErrorCode.NotFound => HttpStatusCode.NotFound,
ErrorCode.InternalServerError => HttpStatusCode.InternalServerError,
_ => HttpStatusCode.BadRequest
};

return response.ToActionResult();
}
4 Replies
n8ta
n8ta14mo ago
Stack Overflow
Increase upload file size in Asp.Net core
Currently, I am working with Asp.Net Core and MVC6 need to upload file size unlimited. I have searched its solution but still not getting the actual answer. I have tried this link If anyone have ...
SwaggerLife
SwaggerLife14mo ago
@Nathaniel TA Thanks mate, after a lot of testing. I realized it was using IIS in Debug and Kestrel in Production. I changed it to use Kestrel on both debug and production. For some reason, the attribute then started working. It sounds weird.
n8ta
n8ta14mo ago
@SwaggerLife I think IIS has an internal limit that was rejecting it before it even reached your service. np
Accord
Accord14mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts
❔ How can I solve this error "does not exist in current context" in C#?I am stuck with this error. I have attached images. Will kindly request if someone can guide me wher✅ WASM project running on local networkNot sure if this really a C# thing, but maybe someone has done this before. We have a Net7 Blazor WA❔ Need help with WFP softwareIm trying to make a map location softoware using google's API. When I embed google maps on my webro❔ question about console app host.RunAsync();In this example: https://learn.microsoft.com/en-us/dotnet/core/extensions/logging-providers using M❔ Entity Framework + Docker sql server on ubuntuthe error A connection was successfully established with the server, but then an error occurred du❔ Need help with LunarVim Nerd Font IconsI'm using JetBrainsMono Nerd Font from nerdfonts.com, but they removed the icon for C#, and im tryin❔ How would I start learning C#?I want to start learning C# for unity programming, and I have a general idea of to code, but have no❔ How do I prevent access to a web server (web api application) from certain clients?I have a web api running on azure. I also have 2 clients, 1 android app and 1 ios app. The client us❔ How do I disable live/realtime linting in VS Code with the C# extension?I'm new to using VS Code (and C#). I installed the C# extension and there is linting while I type an❔ Update Form in a new Thread!I created a form with a datagridview. Now I want to run a powershell command in a new thread and in