Standalone MVC3 webapp?

大城市里の小女人 提交于 2019-12-11 00:03:36

问题


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!


回答1:


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:

  • Neokernel (Not free)
  • C# WebServer (Open source)
  • IIS Express may be an option, but as far as I aware the emphasis is on providing a web server for development and so at the momoment I'm not sure that redistributables are 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!)




回答2:


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).



来源:https://stackoverflow.com/questions/6762193/standalone-mvc3-webapp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!