Can an application be designed with presentation layer in ASP.net and Windows Forms with common code behind
Need: create application that runs on local开发者_如何学JAVA windows client and website. They require simular interfaces although the client application must have a very rich interface. Window Forms application and ASP.Net (MVC) is perferred technology.
Is it really possible (and worth the effort) to share the business logic and datastorage between both applications?
It's probably not going to be practical too share to much in terms of the 2 UIs (if you stick with winforms and asp.net) without using some pre existing framework (I think devexpress has one called XAF that lets you build x platform apps, but I have never tried it)
However there are lots of things you can share depending on your design. You can push a lot of your functionality down into a common shared Business Tier. Using Web services is a great way to do this and can easily be accessed from both applications.
This also abstracts away all your data access so that you only have to build that once. @djohnsonm is correct in that you can share much more code between WPF & Silverlight. However with silverlight being available both in and out of browser it might be worth considering just building the silverlight version and deploying it to both environments. Whether or not this is practical would depend on your target users and environments.
business logic and data storage can absolutely be shared no problem, as long as coded properly and they don't take a dependency on higher components (web or winforms), where code will differ quite a bit is on the presentation layer of course, on one side you'll have the windows form, on the other html so that's completely different, then the layer responsible for responding to events, on MVC you will have your controllers, on WinForms I would recommend you use the MVP pattern, it works quite well, but then writing to the views is a bit different there, on MVC you fill up a view model (one per page) and pass it to the view, on MVP you have an IView and you write to it, the IView will probably have a lot more stuff (and you mention that the client app would have very rich interface) than a view model would have, so they're not quite compatible, but other than the presentation layer and infrastructure, your business and DAL should be reusable, and the fact that they are, will tell you that you coded them well; don't write any logic on your Presenters or Controllers, the trick is simple, if you need to perform actions on the front end based on some business logic, take an interface and use that from your business layer to communicate
I wouldn't go Windows Forms if you are looking to build a RIA. If you really want a rich user interface I would try WPF or Silverlight (you can get great effects using Expression Blend). Although you could just create similar effects using jquery in an ASP.NET MVC 3 Application. This would eliminate the need to build two apps with different business logic and data storage. As best practice I would never build two identical apps on different platforms. It is twice the work and a 1:1 parody cannot always be reached in regards to delivery of features.
精彩评论