Activities of "Sturla"

One more related question, how can I add custom header to the response?

This doesn't work in the controller Response.Headers.Add("BlobName", "content"); but I can still manipulate the response like with Response.ContentType = "THIS IS RETURNED!!"

public virtual async Task Save(IList<IRemoteStreamContent> UploadRecording) 
{
    try
    {
        Response.Headers.Add("CustomHeader", "someContent"); //<-- Isn´t returned!
        Response.ContentType = "THIS IS RETURNED!!"; //<-- BUT this is!
    }
    catch (Exception e)
    {
        Response.Clear();
        Response.StatusCode = 204;
        
        Response.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase = "File failed to upload";
        Response.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase = e.Message;
    }
}

Here in Blazor I'm trying to get the response back when successfully uploaded a file to the controller.

I'm just going after the Syncfusion example so there must be something else I need to do ?

Answer

I needed (I think) to add the following web.config to the HttpApi.Host project to increase upload size with the following config

<?xml version="1.0" encoding="utf-8"?>
<configuration>

  <!-- To customize the asp.net core module uncomment and edit the following section. 
  For more info see https://go.microsoft.com/fwlink/?linkid=838655 -->
  <!--
  <system.webServer>
    <handlers>
      <remove name="aspNetCore"/>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
    </handlers>
    <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
  </system.webServer>
  -->
  <location path="Recording/recording-upload">
    <system.webServer>
      <security>
        <requestFiltering>
          <requestLimits maxAllowedContentLength="4096000" />
        </requestFiltering>
      </security>
    </system.webServer>
  </location>
</configuration>

And then I get this error when running the app with Azure Appservice

2021-12-21 13:54:57.472 +00:00 [ERR] Connection ID "17509995361417066312", Request ID "80007749-0002-f300-b63f-84710c7967bb": An unhandled exception was thrown by the application.
Volo.Abp.Http.Client.AbpRemoteCallException: Not Found
   at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase`1.ThrowExceptionForResponseAsync(HttpResponseMessage response)
   at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase`1.RequestAsync(ClientProxyRequestContext requestContext)
   at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase`1.RequestAsync[T](ClientProxyRequestContext requestContext)
   at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase`1.RequestAsync[T](String methodName, ClientProxyRequestTypeValue arguments)
   at Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ClientProxies.AbpApplicationConfigurationClientProxy.GetAsync()
   at Volo.Abp.AspNetCore.Mvc.Client.MvcCachedApplicationConfigurationClient.<GetAsync>b__14_0()
   at Volo.Abp.Caching.DistributedCache`2.GetOrAddAsync(TCacheKey key, Func`1 factory, Func`1 optionsFactory, Nullable`1 hideErrors, Boolean considerUow, CancellationToken token)
   at Volo.Abp.AspNetCore.Mvc.Client.MvcCachedApplicationConfigurationClient.GetAsync()
   at Volo.Abp.AspNetCore.Mvc.Client.RemoteLanguageProvider.GetLanguagesAsync()
   at Microsoft.AspNetCore.RequestLocalization.DefaultAbpRequestLocalizationOptionsProvider.GetLocalizationOptionsAsync()
   at Microsoft.AspNetCore.RequestLocalization.AbpRequestLocalizationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContextOfT`1.ProcessRequestAsync()

I haven't tried to upload a bigger file than 30 MB but if that doesn´t work without the web.config file I´ll need some way to add it. But I´ll try that tomorrow.

Thank you! I'll then use IRemoteStreamContent Now closing this

Ok ok that was not obvious so thank you so much!

But should I use IList<IFormFile> or IList<IRemoteStreamContent> because both work?

Is there any benefit for me using IList<IRemoteStreamContent> here?

Yes I have decided to go with Syncfusion (or at least try to get it to work) but am having issues with that and created this ticket here for that. So I'll close this one and hope you can help me with the other one (where IRemoteStreamContent is not solving my issue).

I have just updated my demo repo with the code for you to try out. Just F5 and upload file with Browse

Here is the Blazor code and here is the API that gets hit but is always empty (except with SwaggerUI).

Sorry that doesn't work. I have tried every mutation of that. I just don't understand that it works with SwaggerUI but not Blazor if there is no setting or something I need to configure...

After trying things out and searching the internet for answers I found out that Blazor WASM 5.0 does only support ~<2GB upload it seems. I asked this question here that will hopefully move me in the right direction.

But if all fails I will try out this Syncfusion large-file-chunk-upload. Isn't that something you should offer in the framework, large file upload?

How does the File Management Module deal with such large files?

Thank you for your answer Maliming, I haven't tried this with huge files yet (will today) but I was wondering what approach you would recommend taking to upload to blob from the service. Stop in a temp file or directly from stream?

public async Task<string> UploadBigFileAsync(IRemoteStreamContent streamContent)
{
    var filePath = Path.GetTempFileName();

    // use local temp file
    using (var fs = new FileStream(filePath, FileMode.Create))
    {
        await streamContent.GetStream().CopyToAsync(fs);
        await fs.FlushAsync();
    }

    var blobName = $"Uploaded-{streamContent.FileName}";

    // then read it to blob
    var bytes = await File.ReadAllBytesAsync(filePath);
    await blobContainer.SaveAsync(blobName, bytes, overrideExisting: true);

    return blobName;
    
    //delete file finaly()
}

Or just stream it directly

public async Task<string> UploadBigFileAsync(IRemoteStreamContent streamContent)
{
    var blobName = $"Uploaded-{streamContent.FileName}";
    
    await blobContainer.SaveAsync(blobName, streamContent.GetStream(), overrideExisting: true);

    return blobName;
}

I updated the code in my github question to have both a none-working abp version and a working classic Blazor/api that works.

Hopefully this is just some configuration problem but I haven't found it.

Showing 181 to 190 of 218 entries
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.1.0-preview. Updated on October 30, 2025, 06:33