Asp.Net MVC Controller: declarative AOP with Spring.Net

Is it possible that Spring.Net Aspects do not work with the Asp.Net controller?

I want to configure transactions using Action methods for controllers, but the proxy server is down.

<object id="ControllerClassPointcut" type="Spring.Aop.Support.SdkRegularExpressionMethodPointcut, Spring.Aop">
  <property name="patterns">
    <list>
      <value>xxx.Controllers.CompanyController.*</value>
    </list>
  </property>
</object>

<aop:config>
  <aop:advisor pointcut-ref="ControllerClassPointcut" advice-ref="TxAdvice"/>
  <!-- TxAdvice taken from ServiceContext -->
</aop:config>

<tx:advice id="TxAdvice" transaction-manager="TransactionManager">
  <tx:attributes>
    <tx:method name="*" propagation="Required"/>
  </tx:attributes>
</tx:advice>

and CompanyController action method:

    [HttpPost]
    public virtual ActionResult Create(Guid id, CompanyonViewModel vm)
    {
       ...
    }

but I advice does not take effect, although the pointcut is recognized. If I take a class other than a controller, like a pointcut, it will work.

for some methods, advice works. For example, for the installer for the repository. But Sprint.Net does not recognize that the Create action method is called

: "xxx.Controllers.CompanyController.set_CompanyService"; pattern is 'xxx.Controllers.CompanyController. *'; = True [DefaultObjectFactoryPointcutAdvisor: pointcut [ Spring.Aop.Support.SdkRegularExpressionMethodPointcut]; object = 'TxAdvice'], targetType [xxx.Controllers.CompanyController]

+3
2

[Transaction] ( Spring.AOP). [Transaction] , .

, [Transaction], , AOP-proxied, .

MVC, URL ( IControllerFactory). Execute, , , . , . , . , pointcuts , .

, pointcut

, pointcut , , : , , , AOP- .

... ... ,

, () CompanyController.CustomerController CustomerRepository, DI. , pointcut , CompanyController.CustomerController, , DI ( ControllerFactory).

, , . , .

+2

<aop:config proxy-target-type="true">

-, . spirng.net ( 1.3.0).

+4

Source: https://habr.com/ru/post/1776951/


All Articles