I'm at very beginning of learning new version of ASP.Net 5, and at this point I'm already impressed about all new features they introduced. The most awaited by me is built-in DI system.
我开始学习新版本的ASP。Net 5,现在我已经对他们引入的所有新特性印象深刻。我最期待的是内置的DI系统。
Currently I'm working in a company with about 15 sites, and all of them are almost similar by structure but each one have few individual things.
目前我在一家拥有15个网站的公司工作,所有网站的结构都很相似,但每个网站都有一些单独的东西。
So, I plan to do some kind of mini CMS for our sites, something like modularity in PRISM, using new features of vNext.
因此,我计划为我们的站点做一些小型的CMS,像PRISM中的模块化,使用vNext的新特性。
Now, I'm trying to make few basic middlewares (like store, services, blog, chat or whatever), but I'm stucked here.
现在,我正在尝试制作一些基本的中间件(比如商店、服务、博客、聊天或其他),但我在这里感到困惑。
Question 1: Can middleware be used to act as independent modules for a site with his own routes, controllers, admin panel extensions, etc.?
问题1:中间件是否可以作为站点的独立模块,具有自己的路由、控制器、管理面板扩展等等?
if - yes, then...
如果——是的,那么……
Question 2: How can I handle routing requests from Invoke method of middleware?
问题2:如何处理来自中间件调用方法的路由请求?
I read all the docs available for now at http://docs.asp.net, but middleware example used there is pretty simple, isn't enought to start writing middleware used in real-world app.
我在http://docs.asp.net中阅读了所有可用的文档,但是使用的中间件示例非常简单,不应该开始编写实际应用中使用的中间件。
Edit 1: I'm wondering, if middleware can act like IModule in PRISM?
编辑1:我在想,中间件是否可以像PRISM中的IModule一样?
In PRISM, I register types and views inside of IModule, it's like a glue for all module's components. For example: I have PRISM based application with few modules: Accountant, Products, Documents, Mailer and so on. Each module have its own Models, ViewModels, Views, etc, and almost each module can be decoupled or modified without affecting another one. Each doing his job without really knowing about other modules.
在PRISM中,我在IModule中注册类型和视图,它就像所有模块组件的胶水。例如:我有基于PRISM的应用程序,它只有几个模块:会计、产品、文档、邮件等等。每个模块都有自己的模型、视图模型、视图等,几乎每个模块都可以被解耦或修改,而不会影响另一个模块。每个人都在做他的工作而不知道其他的模块。
I'm trying to understand if I can do something like that for web using vNext. For example: Blog module doesn't need to know something about Store.
我想知道我是否可以用vNext做一些类似的事情。例如:Blog模块不需要了解Store。
So, can I do separate Class Libraries for each needed module, and use middleware like I use IModule in PRISM?
那么,我可以为每个需要的模块单独使用类库,并且使用像我在PRISM中使用IModule的中间件吗?
P.S. Any example will be greatly appreciated. Thanks in advance.
附注:任何例子都将不胜感激。提前谢谢。
1 个解决方案
#1
1
Middlewares in ASP.NET replace http modules. You can't build
中间件)在ASP。净代替http模块。你不能建立
store, services, blog, chat or whatever
存储,服务,博客,聊天等等
using http modules (or middlewares). They work in a context of a http request.
使用http模块(或中间件)。它们在http请求的上下文中工作。
The modules you are talking about are higher level concepts. It's a different level of abstraction.
您正在讨论的模块是高级概念。这是一个不同的抽象层次。
Answering your questions:
回答你的问题:
- They are not the type of modules you're thinking of. No
- 它们不是你想要的那种模块。没有
- MVC middlewares already handle routing. I don't think you need to reimplement this. Just use it.
- MVC中间件已经处理了路由。我不认为你需要重新实现它。只是使用它。
#1
1
Middlewares in ASP.NET replace http modules. You can't build
中间件)在ASP。净代替http模块。你不能建立
store, services, blog, chat or whatever
存储,服务,博客,聊天等等
using http modules (or middlewares). They work in a context of a http request.
使用http模块(或中间件)。它们在http请求的上下文中工作。
The modules you are talking about are higher level concepts. It's a different level of abstraction.
您正在讨论的模块是高级概念。这是一个不同的抽象层次。
Answering your questions:
回答你的问题:
- They are not the type of modules you're thinking of. No
- 它们不是你想要的那种模块。没有
- MVC middlewares already handle routing. I don't think you need to reimplement this. Just use it.
- MVC中间件已经处理了路由。我不认为你需要重新实现它。只是使用它。