Hello In Abp, is there a standard way to intercept AppService or DomainManager so that I run some checking code before running the method?
The concept is similar to ASP. NET filters. I'm wondering if Abp offers a way to define such interceptors.
If not. An ASP. NET filter can be used for AppService methods?
Thanks
13 Answer(s)
-
0
Hi ,
ABP does not offer anything for defining interceptors. You can use Castle Windsor's interceptors directly. You can check implementation of ValidationInterceptor, see <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp/Runtime/Validation/Interception/ValidationInterceptor.cs">https://github.com/aspnetboilerplate/as ... rceptor.cs</a>
App services are considered as controllers in ASP.NET Core version, so for them, you can add your custom filters as well.
Thanks.
-
0
Thanks Ismail. I will check the link.
When you say, AppServices are considered as controllers in ASP.NET Core. What have been changed from ASP.NET MVC to ASP.NET Core to make AppServices as controllers? Isn't still the controllers dynamically generated in ASP.NET core?
Thanks
-
0
Hi @bilalhaidar,
ASP.NET Core allows us to use regular classses like controllers. ASP.NET MVC 5.x was not allowing that.
-
0
That's correct. Was that fact reflected in the way you generate the controllers? I assume you still generate controllers dynamically, right?
-
0
Hi @bilalhaidar,
No, actually we don't generate in ASP.NET Core, App services are used directly but of course there are some interceptions while using app services.
-
0
Thanks a lot. I will look into the ASPNET ZERO Core project to see what have been done.
Thanks
-
0
Hello Ismail,
I am trying to add a new Filter to the AppService assembly instead of using a Castle Windsor Interceptor.
To create a new Controller's Filter, I must implement the interface (IAsyncActionFilter). This interface belongs to Microsoft.AspNetCore.Mvc.Abstractions.dll assembly.
Shall I add a reference to that assembly into the AppService layer? My first thought would be against adding that, but what do you suggest?
Shall I stick to an interceptor instead?
Thanks
-
0
Hi,
Let's continue here <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/issues/549">https://github.com/aspnetzero/aspnet-ze ... issues/549</a> if it is the same case :)
-
0
Hi Ismail,
Actually, I am asking here about MVC Filters and not Castle Windsor interceptors. You once mentioned I can add MVC Filters to AppServices since with ASP.NET Core AppServices are considered controllers.
But then I noticed that I need to add some AspNet Core Dlls to the .Core project, so is that correct to do? Or better not to mix AspNet Core dlls inside .Core layer?
Thanks
-
0
Hi,
Yes, it is better not to add ASP.NET Core dll's to your core project. Interception is a better choice for you I think.
-
0
Thanks. Can you please follow up on the GitHub issue I posted? You asked me if my AppService methods are designated with virtual or not. I really appreciate if you can have a look at it. Thank you
-
0
Hi @bilalhaidar,
It seems like you have solved the problem.
-
0
I couldn't have solved it without your assistance.
Thanks a lot