Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

How to Extend Blazor WebSocket Buffer on WebAssembly Hosted Solution

$
0
0

I have a blazor WebAssembly Hosted Solution (.net 6) and am having issues with a RadzenFileInput. The error is that the fileSize is to large. I am using this as a photo upload and the file size of this photo is 5761KB as a png. Radzen support has suggested increasing the buffer size as shown here

https://github.com/radzenhq/radzen-blazor/blob/master/RadzenBlazorDemos.Server/Program.cs#L17

However, does not look like I am running the same version of Blazor as them. My Server Program.cs is as follows

public class Program{    public static void Main(string[] args)    {        var configuration = new ConfigurationBuilder()            .SetBasePath(Directory.GetCurrentDirectory())            .AddJsonFile("appsettings.json")            .Build();        Log.Logger = new LoggerConfiguration()            .ReadFrom.Configuration(configuration)            .Enrich.WithProperty("InstanceId", Guid.NewGuid())            .Enrich.WithProperty("Origin", "Server")            .CreateLogger();        try        {            Log.Information("Starting up");            CreateHostBuilder(args).Build().Run();        }        catch (Exception ex)        {            Log.Fatal(ex, "Application start-up failed");        }        finally        {            Log.CloseAndFlush();        }    }    public static IHostBuilder CreateHostBuilder(string[] args) =>        Host.CreateDefaultBuilder(args)            .UseSerilog()            .ConfigureWebHostDefaults(webBuilder =>            {                webBuilder.UseStartup<Startup>();            });}

I have attempted to add the same within the Server StartUp.cs within the Configure Method however AddRazorComponents() doesnt exist.

public void ConfigureServices(IServiceCollection services){    //Register the Datacontext and Connection String    services.AddDbContext<DataContext>(options =>        options.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking)        .UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))    );    services.AddDatabaseDeveloperPageExceptionFilter();    //Sets up the default Asp.net core Identity Screens - Use Identity Scaffolding to override defaults    services.AddDefaultIdentity<ApplicationUser>(options =>            {                options.SignIn.RequireConfirmedAccount = true;                options.Password.RequireDigit = true;                options.Password.RequireLowercase = true;                options.Password.RequireUppercase = true;                options.Password.RequiredUniqueChars = 0;                options.Password.RequireNonAlphanumeric = false;                options.Password.RequiredLength = 8;                options.User.RequireUniqueEmail = true;                //if (!string.IsNullOrEmpty(Configuration.GetSection("IdentityServer:IssuerUri").Value))                //{                //    options.Tokens.AuthenticatorIssuer = Configuration.GetSection("IdentityServer:IssuerUri").Value;                //}            })        .AddRoles<IdentityRole>()        .AddEntityFrameworkStores<DataContext>();    //Associates the User to Context with Identity    services.AddIdentityServer(options =>    {        //if (!string.IsNullOrEmpty(Configuration.GetSection("IdentityServer:IssuerUri").Value))        //{        //    options.IssuerUri = Configuration.GetSection("IdentityServer:IssuerUri").Value;        //}    }).AddApiAuthorization<ApplicationUser, DataContext>(options =>    {        options.IdentityResources["openid"].UserClaims.Add(JwtClaimTypes.Role);        options.ApiResources.Single().UserClaims.Add(JwtClaimTypes.Role);    });    JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Remove(JwtClaimTypes.Role);    //Adds authentication handler    services.AddAuthentication().AddIdentityServerJwt();     services.AddHttpContextAccessor();    //Send Grid Email Sender    services.AddTransient<IEmailSender, EmailSender>();    services.AddTransient<ISendGridEmailSender, SendGridEmailSender>();    services.ConfigureApplicationCookie(o =>    {        o.ExpireTimeSpan = TimeSpan.FromDays(5);        o.SlidingExpiration = true;    });    services.Configure<DataProtectionTokenProviderOptions>(o => o.TokenLifespan = TimeSpan.FromHours(3));    //Register Radzen Services    services.AddScoped<DialogService>();    services.AddScoped<NotificationService>();    services.AddScoped<TooltipService>();    services.AddScoped<ContextMenuService>();    services.AddControllersWithViews();    services.AddRazorPages();}

I have tried adding

services.AddServerSideBlazor().AddHubOptions(o =>{    o.MaximumReceiveMessageSize = 10 * 1024 * 1024;});

and

services.Configure<HubOptions>(options =>{    options.MaximumReceiveMessageSize = 10* 1024 * 1024;});

Both do not fix the issue. Is there a way to increase the buffer size on a webassembly hosted solution?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>