Base solution for your next web application
Open Closed

.NET Core ActionFilter For Services #5594


User avatar
0
cmthomps created

We're trying to add a new action filter to our application services. We're running the CORE/jQuery version (v5.3) of AspNetZero. The filter needs to inherit from IActionFilter which requires a reference to Microsoft.AspNetCore.Mvc. The current Application project in AspNetZero does not have that reference so we're not sure which is the best project to put the new filter. We've thought about just adding a new project to the solution but we are not confident that is the best approach.

The second question is how do we register the new filter so that it can be used by a service. In this link [https://forum.aspnetboilerplate.com/viewtopic.php?f=5&t=10803&p=27013&hilit=action+filter+api#p27013]), the is a reference to adding it in the startup class in Web.Host project but that project doesn't exist anymore in newer versions of AspNetZero. Can you point us in the right direction for that as well?

Thanks, Craig


5 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    @cmthomps you can define and add the filter in MVC project similar to mentioned forum post.

    Host project should exist in MVC (ASP.NET Core & jQuery) version as well. You shouldn't define/add filter on it but it should exist.

  • User Avatar
    0
    ismcagdas created
    Support Team

    @cmthomps any news ? did that work for you ?

  • User Avatar
    0
    cmthomps created

    I didn't work for me, but I honestly haven't had a ton of time to keep researching. The problem that I've got is that I want to add an ActionFilter that will use eTags so that clients will cache some API results and those components have dependencies on the MVC dlls. As an example, this is one that I was going to try.

    https://gist.github.com/madskristensen/36357b1df9ddbfd123162cd4201124c4

    Is there anything built into ABP that would accomplish the same thing? Any advice?

    Thanks, Craig

  • User Avatar
    0
    ismcagdas created
    Support Team

    @cmthomps the example you shared is a middleware and it is used on the MVC project's Startup file. Why don't you use it like that ? I couldn't understand that part, sorry.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Closing due to inactivity. Please reopen if you are still having this problem.