独立的 MVC3 Web 应用程序?
我不想走 Silverlight/WPF 路线,而是想在 HTML5 中构建我的(单用户)应用程序,并以 MVC3 作为后端。这可能吗?将其用于独立的桌面应用程序是否可能或实用?
我可以在 IIS 中设置它,然后就可以了,但这不是我的想法 - 它不可移植,需要一个固定的目录,而且我不能在不安装 IIS 的情况下在任何地方启动我的应用程序!
Rather than going down the Silverlight/WPF route, i'd like to build my (single-user) application in HTML5 with MVC3 as the backend. Is this possible? Is it possible or practical to use this for a standalone desktop application?
I could set it up in IIS and off I go, but that's not the idea - its not portable, requires a fixed directory, and I can't just fire up my application anywhere I take it without installing IIS!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我已经尝试过一个独立的进程内基于 .Net 的 Web 服务器,它能够托管 MVC 应用程序 - 这当然是可能的,您可以在独立应用程序中使用这样的 Web 服务器,也可以与 Windows 应用程序中的 Web 浏览器控件结合使用,或者仅使用普通浏览器,类似于 Visual Studio 2010 中帮助系统的工作方式。
有几个可用选项:
另一个问题有答案 这涵盖了使用 IIS 可托管 Web 核心,它看起来非常简洁,但需要在计算机上安装 IIS 7。
或者,我尝试自己编写一个小型网络服务器来完成此任务。这确实没那么难,但棘手的是让我的 Web 服务器在处理 ASP.Net 请求时表现得与 IIS 完全相同。尽管它至少适用于某些 MVC 应用程序,但它绝对不适用于所有 MVC 应用程序,并且几乎肯定需要进行一定量的“调整”才能使其一切正常工作,具体取决于MVC 应用程序的复杂性。
如果您想了解它的工作原理并尝试编写自己的代码,可以在 CodePlex 上找到我编写的代码(或者根据您自己的目的调整它 - 如果您想要它的非开源许可版本,那么就问吧)
如果您想要一个工作的 Web 服务器,尽管 C# WebServer 是一个更好的选择(尽管我没有真正使用过它,所以不要不太了解它是如何发生的作品)。
(有一天我可能会抽出时间来完成我的网络服务器,但目前我还有太多其他项目!)
I have experimented with a standalone in-process .Net based web server that has the ability to host MVC apps - its certainly possible and you could use such a web server in a standalone application either in conjunction with a web browser control in a Windows application, or just with a normal browser similar to the way that the help system in Visual Studio 2010 works.
There are a few options available:
There is an answer on another question that covers using the IIS hostable web core which looks very neat, however requires that IIS 7 be installed on the machine.
Alternatively I had a go at writing a small web server myself that did just this. It really wan't that hard, but the tricky thing was getting my web server to behave exactly as IIS does when handling ASP.Net requests. Although it does work with at least some MVC applications, it definitely doesn't work with all MVC applications and a certain amount of "tweaking" would almost certainly be required to get it everything to work depending on the complexity of the MVC app.
The one I wrote is available on CodePlex if you want to see how it works and try and write your own (or adapt it for your own purposes - if you want a non open-source licensed version of it then just ask)
If you want a working web server though C# WebServer is a better bet (although I've not really used it and so don't know that much about how it works).
(I might get around to finishing my web server one of these days, but at the moment I have too many other projects!)
我想到的第一个选项是使用 IIS Express ,它基本上是一个可以放在口袋里随身携带的小型 IIS。不过,我不知道在这种情况下您的应用程序的安装情况是什么(您是否必须安装 IIS Express,然后安装您的应用程序,或者您是否可以一次性完成这一切)。
The first option that comes to mind is to use IIS Express, which is basically a little IIS you can carry around in your pocket. I don't know what the installation story would be for your app in this case, though (whether you would have to install IIS Express, and then your app, or whether you could do it all in one go).