Dear Team, i used the abp generate-proxy -t csharp -url https://localhost:44358 command and generated c# client proxies. Now i created a new empty blazor app using "dotnet new blazorwasm -o ProMailNet.BlazorWasm" and would like to use this proxy by injecting it. Is there any way to achieve that ?
I was able to inject it into my program.cs and referenced the project http.client.
builder.Services.AddScoped<MailboxClientProxy>();
but when i try to call a method from the mailboxclientproxy :
Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100] Unhandled exception rendering component: Object reference not set to an instance of an object. System.NullReferenceException: Object reference not set to an instance of an object. at Uncaught (in promise) Error: Volo.Abp.AbpException: WebAssemblyCachedApplicationConfigurationClient should be initialized before using it.
would really appreciate your help. as i am trying to create an empty blazor app but use the proxies. The reason for that is that currently my blazor application hosted on https://uat.promailnet.com takes upto 6 seconds before reaching the appliction-configuration call which is leading to super slow load time. everytime you refresh it does the same thing. it caches everything else, but this call takes 6 seconds to initiate, so im starting with a blank template as i only require the proxies for some app services. I am handling everything else
- ABP Framework version: 5.2
- UI type:/ Blazor
- DB provider: EF Core /
- Tiered (MVC) or Identity Server Separated (Angular): no
- Exception message and stack trace:
- Steps to reproduce the issue:"
5 Answer(s)
-
0
hi
You need to bootstrap the abp module system in your blazor wasm project.
public class Program { public async static Task Main(string[] args) { var builder = WebAssemblyHostBuilder.CreateDefault(args); var application = await builder.AddApplicationAsync<MyProjectNameBlazorModule>(options => { options.UseAutofac(); }); var host = builder.Build(); await application.InitializeApplicationAsync(host.Services); await host.RunAsync(); } }
https://docs.abp.io/en/abp/latest/API/Static-CSharp-API-Clients
-
0
Hello, thanks for the advice, ok so now its calling the api endpoint but the token isnt being passed and my endpoints returns Unauthorized:
I have my own login page which was implemented and working on my original blazor UI project. i copied the same config to this project as follows
public override void ConfigureServices(ServiceConfigurationContext context) { var environment = context.Services.GetSingletonInstance<IWebAssemblyHostEnvironment>(); var builder = context.Services.GetSingletonInstance<WebAssemblyHostBuilder>();
ConfigureAuthentication(builder); ConfigureHttpClient(context, environment); ConfigureBlazorise(context); ConfigureRouter(context); ConfigureUI(builder); ConfigureAutoMapper(context); context.Services.AddScoped<TokenServerAuthenticationStateProvider>(); context.Services.AddScoped<AuthenticationStateProvider>(provider => provider.GetRequiredService<TokenServerAuthenticationStateProvider>()); }
Would it be possible to create a working example project ? would really appreciate it , already my application is down to 1.9 seconds load now, just need to fix the token header.
-
0
Update : I got the JWT token to work but i am having a weird issue while generating the proxies using : abp generate-proxy -t csharp -u https://localhost:44358
some of the proxies generated have this issue for some of the functions, i cant see anything in common with those functions :
public virtual GroupDto GetByFriendlyUrl(string url, Guid pmnId) { //Client Proxy does not support the synchronization method, you should always use asynchronous methods as a best practice throw new System.NotImplementedException(); }
However , my function is actually Async as can be seen here :
public interface IGroupAppService : IApplicationService { Task<PagedResultDto<GroupDto>> GetListAsync(GetGroupsInput input);
Task<GroupDto> GetAsync(Guid id); Task DeleteAsync(Guid id); Task<GroupDto> CreateAsync(CreateOrUpdateGroupInput input); Task<GroupDto> UpdateAsync(CreateOrUpdateGroupInput input); Task<List<GroupDto>> GetMyGroups(Guid pmnId); Task<GroupDto> GetByFriendlyUrl(string url, Guid pmnId); Task SetAllGroupsFullPath(); }
-
0
Update : I figured it out , it was the names of the functions , the name convention needed the word Async at the end of function names !
-
1
And btw thanks alot , you always provide timely and great support, much appreciated :)