用于 .NET 应用程序的嵌入式 Web 服务器和 GUI 框架
我正在寻找一个框架,它允许我通过基于网络的 GUI(使用嵌入式网络服务器)而不是 winforms 来管理我的应用程序。
像这样的东西: http://www.webtoolkit.eu/wt 但对于 .NET
在我的我应该能够实例化类(如按钮、表单等),并且当用户浏览到给定端口时,应用程序应将其呈现为 javascript/ajax 等。 最好,当按下按钮时,应该调用我的代码中的通知。
与我发布的有关 extjs 的另一个问题相比,这是一个不太具体的问题。 我希望这会吸引更多观众,因为它更通用,
谢谢。
更新:
类似卡西尼号的解决方案不符合要求。 由于 Web 浏览器嵌入在我的应用程序中,因此不需要 ASP.NET 服务器端脚本。 我宁愿拥有框架,当页面上发生事情时调用应用程序内部的函数。 例如 onButtonClicked()。
I'm looking for a framework which allows me to manage my application through a webbased GUI (using an embedded webserver) instead of winforms.
Something like this: http://www.webtoolkit.eu/wt but then for .NET
In my code I should be able to instantiate classes (like buttons, forms etc), and when a user browses to a given port, the app should render it as javascript/ajax etc etc.
preferably, when buttons are pushed, a notification in my code should be called.
this is a less specific question than another one I posted about extjs. I hope this will attract more viewers since it is more generic
Thanks.
Update:
cassini like solutions don't fit the bill. Since the webbrowser is embedded in my application, there is no need for ASP.NET server side scripts. I would rather have the framework, call functions inside my application when things happen on the page.
onButtonClicked() for instance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
您可以使用 System.Net.HttpListener 类作为嵌入式网络服务器。 HttpListener 将为您完成低级工作,但您必须自己编写返回 Html/javascript/images 的代码。
我自己尝试一下只是为了好玩,使用 GeckoFx 嵌入 Firefox 中嵌入的 Web 服务器应用程序本身。 看起来效果很好,但我的测试非常简单且有限。
You might use the System.Net.HttpListener class as an embedded webserver. The HttpListener will do the low-level stuff for you, but you will have to write the code that returns the Html/javascript/images yourself.
I tried it out just for fun myself, embedding firefox using GeckoFx against a web server embedded in the application itself. It seemed to work well, but my test was very simple and limited.
嵌入 Cassinni 并使用 ASP.NET 怎么样?
How about embedding Cassinni and using ASP.NET?
您可以在自己的应用程序中托管 ASP.NET 运行时,并使用任何 Web UI 框架(例如 LiveUI 或类似的框架)。 请在此处了解如何执行此操作。
You can host the ASP.NET runtime in your own application and use any web UI framework like LiveUI or something like this. See how to do this here.
如果您可以使用 ASP.NET(使用开发服务器或 cassini),那么您的任务会更简单。 我强烈推荐这种方法。 在这种情况下,您可以使用 liveui、componentart 或 teleric。
liveui 提供基于 Extjs 的框架来实现 3 层 Web 应用程序。
componentart 和 teleric 提供了很好的 ASP.net 控件。
而 webui 可能可以在没有 ASP.net 基础设施的情况下作为 httpHandler 工作。 但我不会推荐使用webui,因为1潜在的性能问题2复杂且不灵活的编程模型。
If you could use ASP.NET (using development server or cassini) then your task would be simpler. I strongly recommend this approach. In this case you could use liveui, componentart or teleric.
liveui provides Extjs based framework to implement 3-tiered web applications.
componentart and teleric provide nice ASP.net controls.
Whereas webui probably can work as httpHandler without ASP.net infrastructure. But I would not recommend to use webui because 1 potential performance problems 2 complex and not flexible programming model.
您的应用程序支持的框架是否受到限制? 如果您可以使用 .NET 3.0+,Windows Presentation Foundation 可以可用于针对 Web(通过 xbapp 或 silverlight)和传统 Windows 窗体应用程序。
就应用程序之间的通信而言,这是Windows Communication Foundation (WCF) 真的很耀眼。
澄清一下,您可以使用 Casini 托管您的 Web 应用程序并使用 WCF 在它和您的应用程序之间进行通信,或者使用 xaml 标记您的应用程序并将其公开为具有相同 UI 的 Web 应用程序和普通 Windows 应用程序。
Are you limited to what framework your application can support? If you can use .NET 3.0+, The Windows Presentation Foundation can be used to target both web (via xbapp or silverlight) and traditional windows form applications.
As far as communication between apps goes, this is where the Windows Communication Foundation (WCF) really shines.
Just to clarify, you could use Casini host your web app and use the WCF to communicate between it and your application, or use xaml to markup your application and expose it as both a web application and a normal windows application with the same UI.
如果您想自动将正在运行的 WinForms 代码转换为 HTML,那么您已经陷入困境了。 我已经用 Visual WebGui 做了类似的事情,但它确实需要修改您的代码并且基本上会生成 ASP。 NET 应用程序——需要一个实际的 Web 服务器来运行它。
我发现您不喜欢卡西尼号选项 - 如果您还希望它在没有网络服务器的情况下也能工作,那么我认为简单的答案是“不可能”。
如果您有一个相对简单的界面,我认为您最好的选择可能是从现有表单或从头开始动态生成 HTML 代码,并使用 System.Net.HttpListener。
If you want to automagically convert running WinForms code to HTML, you're already in deep water. I have done something similar with Visual WebGui, but it does require modifying your code and will basically generate an ASP.NET application for you -- needing an actual web server to run it.
I see you don't like the Cassini option -- if you also expect this to work without a web server, then I think the quick answer is "no way".
If you have a relatively simple interface, I think your best bet is probably to generate the HTML code dynamically, either from your existing forms or from scratch, and go with System.Net.HttpListener.
我很久以前做过一个 .NET 2.0 项目,它基本上有一个 网络浏览器控件。
我将通过 WebBrowser 控件的 Document 属性向其提供 html,并侦听导航事件,以便从我的资源中获取 Html(或立即构建它)并将其再次提供给 WebBrowser 控件。
现在,乐趣从 ObjectForScripting 财产。 这允许您的 html 页面通过 Javascript 与 .NET 对象对话,例如:
window.external.SomeNetFunction(bla)
。不要忘记将
ComVisible
属性添加到ObjectForScripting
中使用的类。我希望这就是您正在寻找的。 在此解决方案中,您有一个可以导航的网页,并且还可以通过 javascript 与您的应用程序通信。 (这样您就可以接近 AIR 的 .NET 版本...)
I did a long time ago, a .NET 2.0 project which basically had a Webbrowser control.
I would feed the WebBrowser control with html through it's Document properties, and would listen to the navigate event, in order to grab the Html from my resource (or build it instantly) and feed it again to the WebBrowser control.
Now the fun starts with the ObjectForScripting property. This allows your html page to talk to a .NET object through Javascript like:
window.external.SomeNetFunction(bla)
.Don't forget to add the
ComVisible
attribute to the class that is used inObjectForScripting
.I hope this is what you are looking for. In this solution you have a webpage which can navigate, and also via javascript can talk with your app. (like this you can come close to a .NET version of AIR...)
DevExpress 有一款产品可以满足您的需求。 不过,您必须为此付出代价...
http://www.devexpress。 com/Products/NET/Application_Framework/
DevExpress have a product that does what you require. You'll have to fork out for it though...
http://www.devexpress.com/Products/NET/Application_Framework/
我建议改用 Linux 路线,并依靠嵌入式 httpd、boa 或类似的东西来缩小规模。 不建议在嵌入式系统上运行Windows,太多的臃肿和太多的安全漏洞。 最好选择 Linux 或 RTOS。
I would suggest going the Linux route instead and rely on something like an embedded httpd, boa, or similar to keep size down. Running Windows is not recommended on embedded systems, too much bloat and too many security holes. Better go with Linux or an RTOS.