Windows窗体和Web窗体的MVC

Windows窗体和Web窗体的MVC

问题描述:



我有一个即将到来的项目,需要将其集成到我们基于Windows和Web托管的产品中.

我当时在想,限制工作重复的最佳方法是使用MVC,因此只有View方面才需要重复.

所以我的问题是,是否有适用于.Net的MVC框架同时适用于基于Web和基于表单的开发?

还是可以提供比MVC更好的方法来最大程度地减少工作重复?

使用其他解决方案时,请记住我无法使用基于Windows的产品访问IIS进行Web托管,因此我无法使用ClickOnce,因为Web版本需要Mac/Linux/Tablet支持,并且我们没有其他开发人员资源比.Net资源要多.

Hi,

I have a project on the horizon which needs to be integrated to both our windows based and web hosted products.

I was thinking the best approach for this, to limit the duplication of work would be to use MVC so only the View aspect would require duplication.

So my question is, are there any MVC frameworks out there for .Net which work well for both web based and form based development?

Or can you provide a better approach than MVC for minimising the duplication of work?

With other solutions keep in mind that I do not have access to IIS for web hosting with our windows based products, I can''t use ClickOnce as Mac/Linux/Tablet support is required for the web version and we have no developer resources other than .Net resources.

如果您想控制UI,则可以使用几种方法来制作UI:WindowsForms,WPF,Silverlight,经典ASP.NET和MVC. html代码.由于WPF和Silverlight都具有XAML引擎(请参见 MSDN [ ^ ]) ,您可以定位此方法.
但是主要的问题是逻辑分离:使用每种基于Web的方法,您都必须处理服务器和客户端.因此,您必须处理无状态问题以及通信问题,带宽问题等.使用桌面应用程序,您可能已经在客户端上安装了所有逻辑.或至少会出现诱惑,以在客户端移动更多逻辑.
如果我理解正确,那么您基于Windows的应用程序将只是一个表示层.但是为什么要打扰呢?
您可以通过MVC踏上一条非常好的道路!如果您不需要极端的GUI,则HTML5使您可以使应用程序看起来像魅力,借助JQuery,它可以像魅力一样在浏览器中运行,现在,通过 ^ ],您甚至可以在IIS外部托管服务器端逻辑.
因此,采用都市圈方法:一切都在浏览器中运行.使您的GUI使用HTML5,CSS3和JQuery,使您的逻辑使用ASP.NET MVC4或您喜欢的任何东西,但不要在服务器端生成html代码.仅从服务器提供静态内容和BL.创建一个小的Windows窗体应用程序,其中包含一个WebBrowser控件(或其他浏览器控件),并向其中添加尽可能少的代码-仅连接到预配置的服务器和基本I/O.
因此,客户将能够使用它的浏览器或这个小应用程序:相同的体验,没有重复的工作,并且没有客户端OS依赖项(但是您将需要一个好的浏览器-否则您必须基于以下内容提供不同的UI:检测到客户端浏览器)

但请澄清一下:Microsoft MVC基于ASP.NET,您需要具有ASP.NET的主机才能运行它.您可以在任何其他平台上创建服务器端逻辑,并通过JSON或XML,或基于Web浏览器或Forms Client的任何东西与之交互.但这将不再是Microsoft ASP.NET MVC.
You have several possibilities to make your UI: WindowsForms, WPF, Silverlight, classic ASP.NET and MVC if you like to have control over html code. As both WPF and Silverlight have XAML engine (see MSDN[^]), you can target this approach.
But the major issue is the separation of logic: with every web based approach you have to deal with a server and a client side. Thus, you have to deal with statelessness and with communication issues, bandwidth problems and so on. With a desktop application you will have probably all the logic installed on the client. Or at least the temptation will be there to move more logic on client side.
If I understand correctly, your windows based application will be only a presentation layer. But Why bothering with it?
You take a really good path with MVC! If you don''t need a extreme GUI, HTML5 gives you the possibility to make application look like a charm, with JQuery it will work in the browser like a charm, and now, with Web API[^] you can even host the server side logic outside IIS.
So, take the metro approach: everything runs in a browser. Make your GUI in HTML5, CSS3 and JQuery, make your logic in ASP.NET MVC4 or whatever you like, but do not generate html code on server side. Serve only static content and BL from the server. Create small windows forms app, that contains a WebBrowser control (or other browser control), and add as less code to it as possible - only to connect to the preconfigured server, and basic i/o.
Thus the customer will be able to use it''s browser or this little app: same experience, no duplicated work, and no client side OS dependency (but you will need a good browser - or you have to serve different UI based on the client browser detected)

But let''s clarify: Microsoft MVC is ASP.NET based, you need an ASP.NET enabled host to run it. You can make the server side logic on any other platform, and interact with it via JSON or XML, or whatever from a web browser based or a forms client. But that will be no Microsoft ASP.NET MVC anymore.