Please help me understand these things:
Since I have to make the API Controller inherit from the related service Interface; I feel my self forced to create an API endpoint for each App service call even if I do not intend to use them (I just leave it as unimplemented sometimes)
Then in many cases and even if it's against what I want to do; whenever I inject the Interface of that service, instead of the SERVICE implementation in the Application project used, the Controller implementation is used. For example, the API is called, not the service directly when I am trying to have an action in the Web project for example when a button is clicked in behind the code (C#). It's weird that the C# app service called the CONTROLLER implementation of the Service interface instead of calling the Service directly using the Application project implementation. The image below if from the submit action of a button in WEB. It should not use the API but it is. It should use the service implementation from Application project directly instead of 2 bounces
In a completely different issue: I find it odd the multi-tiered solution duplicates the /api/ functionality in the WEB url instead of the proper was of calling API url using tokens for example. I noticed that it does this to use the logged-in user auth cookie in the web app. In a tiered application, the API calls are done with JWT token and handles renewal of the tokens etc. I still can not figure out why the Web project is tightly married to the API. Something is off.
Thank you
5 risposte
-
0
Hi
For Tiered project it's required.
The tiered solution is a front-end and back-end separation project.
- MVC is the front-end
- HttpApi.Host is the back-end
The MVC project does not access the database directly(application, domain service). It accesses the backend via HTTP API.
You can see the document:https://docs.abp.io/en/abp/latest/Startup-Templates/Application#tiered-structure
-
0
I do not believe using an App service is "Accessing the database directly" I need a modern application where I do not fuse the Web and API together. these 2 must be separated.
I should be able to make the WEB project dumb.
the JWT token is not really used for API calls instead the Web is tightly coupled with the web.
The separation between:
- API
- Web
- and Auth server
seems wrong.
Why do I have to rout my service calls through API when I a using the code-behine? I should be able to use a call to the Application service directly.
-
0
I need a modern application where I do not fuse the Web and API together. these 2 must be separated.
You can consider using the Angular UI or Blazor UI, they are completely separate.
the JWT token is not really used for API calls instead the Web is tightly coupled with the web.
No, the Web use C# client proxy: https://docs.abp.io/en/abp/latest/API/Static-CSharp-API-Clients to access the API and the JWT token used inside.
I should be able to use a call to the Application service directly.
However, this is by design, but there is no something blocking you, you can change it if you want.
I do not believe using an App service is "Accessing the database directly"
As you know, typically application services use repositories or domain services and they have the ability to access databases.
-
0
Can you explain / example; how to call the service directly from Web code-behind without using the API?
I will look into using Angular.
Thank you
-
0
Hi,
As I said, typically application services use repositories or domain services and they have the ability to access databases.
It is almost indistinguishable from non-tiered:
- Remove
...HttpApiClientModule
fromWebModule
- Remove
AbpAspNetCoreMvcClientModule
fromWebModule
- Remove
AbpHttpClientWebModule
fromWebModule
- Add
..Application
reference to theWeb
project and add..ApplicationModule
to theWebModule
- Add
..EntityFrameworkCoreModule
reference to theWeb
project and add..EntityFrameworkCoreModule
to theWebModule
- Configure
Auto API controllers
:
Configure<AbpAspNetCoreMvcOptions>(options => { options.ConventionalControllers.Create(typeof(MyProjectNameApplicationModule).Assembly); });
- Remove