How to handle cross-cutting issues in an ASP.NET MVC 3 application?

I have an ASP.NET MVC 3 web application with various components / layers, for example:

  • Web
  • Services (cache, external APIs, cloud services, etc.)
  • Kernel (domain logic, POCO, etc.)
  • Repository (Entity Framework)

Now, when I do something on my website (for example, submit a form, as well as POST), in the worst case, all layers may need to be notified.

Now I could build all this logic in the HTTP POST action of my controller, but in the logic it becomes really thick and weighty.

I tried using the Publisher-Subscriber (AOP) template, but have not yet found a very good .NET implementation, and I also had people who told me that this is not good practice for application websites.

Can someone give me some advice here, or am I stuck with this code:

[HttpPost] public ActionResult Do(Something model) { _repository.Save(model); // this should be the only line IMO _service.DoSomething(); _repository.DoSomethingElse(); _domain.DoSomethingMore(); } 

I'm not talking about multithreading or anything like that, but I just take abuse from the controller and put it in components that take care of these actions.

+4
source share
2 answers

One good PubSub script would be Faye , which is built on Node.js. It is really good and can be used for your business.

Faye is a Bayeux- based subscription messaging system. It provides message servers for Node.js and Ruby , and clients for use on the server and in all major web browsers.

+1
source

If you haven't completely abandoned PubSub, you can take a look at RabbitMQ. http://www.rabbitmq.com/

I don’t understand why this is not “best practice” for web applications, these absolutes are rarely correct in any case.

0
source

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


All Articles