I created a module project, defined an interface in the“ Application. Contracts” project, implemented this interface in the” Application” and ”Controller” projects, and used the command ”abp generate proxy - t csharp - url' in the HttpApi. Client project http://localhost:44313 -M WorkCalendar -- without contracts "generated the proxy code, and then I referenced this proxy in ”Blazor. Server. Host ”and started the ”Blazor. Server. Host” and ”HttpApi. Host” projects. At this time, the ”CurrentUser” information obtained from the services in the Application project is null, and the services inherit IApplicationService and ITransientDependency interfaces, How can I obtain information about Blazor login users from the services in the Application project?
Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, and please first use the search on the homepage. Provide us with the following info:
- ABP Framework version: v7.2.2
- UI Type: Blazor Server
- Database System: EF Core (PostgreSQL)
- Tiered (for MVC) or Auth Server Separated (for Angular): yes/no
- Exception message and full stack trace:
- Steps to reproduce the issue:
18 Answer(s)
-
0
Hello cunyong.yu@vskysoft.com,
Can you please share some logs or more steps to reproduce the issue?
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
I started the "AuthenServer", "HttpApi. Host", and "Blazor. Server. Host" services.
Then log in to the 'admin' user on the page.
“Blazor. Server. Host" calls the interface through "HttpApi. Client":
Unable to obtain the current logged in user information in the interface. How can I obtain the logged in user information for calling the interface?
If you need debugging, how can I send you the demo project?Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
hi I have sent the demo to your email.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
- Start the "AuthenServer", "HttpApi. Host", and "Blazor. Server. Host" services.
- Log in to the 'admin' user on the page.
- Open the homepage of UserInfoDemo.
- Break the point in the GetAsync method of 'SampleAppService' to view details of _currentUser. Why there is no login user information in currentUser, or is there any other way to obtain it here.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
I'm very sorry, I missed a decryption file. I have sent it to you via email.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
hi
src/UserInfoDemo.Application/Samples/SampleAppService.cs host/UserInfoDemo.HttpApi.Host/EntityFrameworkCore/UserInfoDemoHttpApiHostMigrationsDbContextFactory.csMarkdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
I'm very sorry for missing it again. It has been sent to you via email.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
hi
The
UserInfoDemo.Blazor.Server.Hostproject is not atieredproject.It has
openiddictintegration and uses cookies. so you can't getaccess_tokenfrom cookies to call the api.Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
In this case, can I only fill in the user information in the Blazor project and then pass it to the interface?
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
-
0
hi
that you call the interface on the Blazor page.
this means the
tieredblazor app which is a pure UI project, your blaozr includes openiddict, account etc, and it is not a UI project.Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
If you still want to call the API
You can add
AbpHttpClientIdentityModelWebModulemodule to your blazor project and override theHttpContextIdentityModelRemoteServiceHttpClientAuthenticatorto return anaccess_token.https://github.com/abpframework/abp/blob/rel-7.2/framework/src/Volo.Abp.Http.Client.IdentityModel.Web/Volo/Abp/Http/Client/IdentityModel/Web/HttpContextIdentityModelRemoteServiceHttpClientAuthenticator.cs#L37-L46
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Can you provide me with a demo? Thank you!
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
hi
You can't get the
access_tokenfromhttpcontextin yourblazorproject by default. Because your situation does not match our design.You can request the auth server get a new access_token and set it to request in your custom
HttpContextIdentityModelRemoteServiceHttpClientAuthenticatorhttps://github.com/abpframework/abp/blob/rel-7.2/modules/openiddict/app/OpenIddict.Demo.Client.Console/Program.cs#L22-L32
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

