推荐的体系结构 - 提供 ASP.NET Web 前端的服务器应用程序
我正在研究开发服务器应用程序的最佳方法,该应用程序提供用于管理/报告的 ASP.NET MVC 前端。
服务器应用程序(服务?)还需要提供 TCP 侦听器以及与 COM 端口上的设备进行通信。
我能想到的最明显的方法是拥有一个 ASP.NET MVC Web 应用程序,并拥有一个使用 Web 调用/服务与 Web 应用程序进行通信的 Windows 服务。我想然后我会使用 tcp 侦听器或远程处理与服务通信?
唯一的其他方法是在服务中实际托管一个 Web 服务器组件,而不是使用 IIS,这似乎有点过头了。
有人有这方面的经验/建议吗?
这有点开放式,但希望我已经解释了基础知识。
蒂亚·
萨姆
I'm having a look at the best way of developing a server application that presents an ASP.NET MVC front end for management/reporting.
The server app (service?) will also need to provide TCP listener as well as communicate to devices on a COM port.
The most obvious way I can think of doing this is to have an ASP.NET MVC web app and have a windows service that talks to the web app using a web calls/services. I guess then I'd talk to the service using the tcp listener or remoting?
The only other way would be to actually host an web server component in the service, and not use IIS which seems a bit to over the top.
Does anyone have any experience of this/recommendations?
It's a bit open ended but hope I've explained the basics.
TIA
Sam
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我可能会尝试将事情进一步解耦。
从一个核心项目开始,您的所有业务逻辑都位于其中(与用户如何与其交互无关);有点像 DDD 领域模型的想法。
然后,创建两个使用该核心项目的项目,一个是您的 MVC 应用程序,另一个是基于 WCF 或 ServiceStack 的服务,可以处理您的 TCP 内容。
使用正常方式在它们之间共享状态;进程间通信、共享数据库等。
I would probably try and decouple things a bit more.
Start off w/ a core project where all your business logic lies (agnostic of how users interact with it); sort of the DDD Domain Model idea.
Then, create two projects which consume that core project, one that is your MVC app, and another that's a WCF or ServiceStack-based service which can handle your TCP stuff.
Share state between them using the normal means; either inter-process comms, shared database, etc.
在我看来,您正在寻找与 Windows Communication Foundation 非常接近的东西。您对 IIS 托管、ASP.NET 通信和 TCP 通信的要求。 MSDN 在此处提供了 WCF 的简要概述。 此处还提供了一篇有关传输协议的文章。
Stack Overflow 上有一些很好的(虽然有点老)WCF 问题。我自己刚刚开始探索这个世界,我不得不承认一开始它是令人畏惧的。初学者指南(可以在上面的第一个超链接下找到)有一些稍旧但非常有用的有关 WCF 的教程视频。
我想说的是,尽管这看起来令人畏惧或困难,但使用现有的、成熟的技术来实现您的目的肯定比尝试为此类问题编写自己的自制解决方案更好。
It sounds to me like you're looking for something very close to Windows Communication Foundation. Your requirements for IIS hosting, ASP.NET communication, and TCP communication. MSDN has a brief overview of WCF up here. There's also an article available about the transportation protocols here.
There are some good -- if a little old -- WCF questions here on Stack Overflow. I've just started delving into this world myself, and I have to admit that it's daunting at first. The Beginner's Guide (found under the first hyperlink above) has some slightly old, but very useful tutorial videos about WCF.
I will say that, although it may seem daunting or difficult, it's certainly better to use an existing, established technology for your purposes than to try to write your own homebrewed solution for something like this.
我启动了 ServiceStack 因为我需要一个 高性能 Web 服务框架选项,促进开发 Web 服务的正确方法< /a>.
ServiceStack 可以在任何 ASP.NET 主机上运行,也可以使用 HttpListener 选项自托管运行。有关控制台应用程序或 Windows 的示例项目,请参阅入门模板服务主机。尽管即使在 IIS 下,ServiceStack 也非常快,并且在 <1ms 响应时间内执行 hello world 服务时产生的开销非常小。
ServiceStack 还附带.NET 最快的文本序列化程序 和无数的高性能缓存提供程序,这样您就可以摆脱 XML 配置绑定 ASP.NET 的会话和缓存提供程序 模型。
由于 ServiceStack 鼓励基于消息的干净开发模型,因此您相同的 Web 服务可以利用 Redis MQ Host 允许使用 Redis 作为代理在 HTTP 上下文之外调用它 - 无需更改代码。
Redis 是 最快的分布式 NoSQL 数据存储。
I started ServiceStack because I needed a high-performance web services framework option that promotes the correct way to develop web services.
ServiceStack can be run on top of any ASP.NET host or self-hosted using the HttpListener option. See the Starter Templates for example projects of a Console App or Windows Service hosts. Although even under IIS, ServiceStack is very fast and imposes very little overhead with a hello world service executing in sub <1ms response times.
ServiceStack also comes with .NET's fastest text serializers and a myriad of high-performance caching providers so you can escape the XML config bound ASP.NET's session and caching provider model.
Because ServiceStack encourages a clean message-based development model your same web services can take advantage of the Redis MQ Host allowing it to be invoked outside of HTTP context using Redis as a broker - with no code-changes required.
Redis is one of the fastest distributed NoSQL data stores.