I didn't think it was possible but I was just talking to a co-worker who said she had done it before. Is she pulling my chain?
相关问题
- Carriage Return (ASCII chr 13) is missing from tex
- Generic Generics in Managed C++
- How to store image outside of the website's ro
- How to Debug/Register a Permanent WMI Event Which
- 'System.Threading.ThreadAbortException' in
just a comment more: the rewrite depends of how much logic is in the form itself. With properly separated concerns, it is only a matter of plugging in another UI onto the business layer.
The problem is, offcourse, that 90% of apps isn't anything more that somewhat complex CRUD UI's (no real business logic)...
Yes, it is possible. If you have designed the application well enough it should be relatively easy to convert a Win Forms application to a web forms application by just swapping out the UI layer and replacing it. You are re-using the logic and data layers (which is where all the functionality would be).
Obviously, you have to write a new UI layer from scratch, but, if the logic layer is written well enough that isn't going to be too much work compared with writing the whole application again from scratch.
However, there are some gotchas even if you have a very well written application. The logic layer may assume a stateful application in which case it may rely on lazy loading. In a web application you have a stateless model which is run on requests and responses. In that scenario you'd know exactly what you need up front and can load just the bits you need and not other things that may be needed later on... because later on will be a different request/response cycle and all the data you collect now is going to be dropped as soon as the current response is completed.
I've recently been putting the logic of an application that was originally a WinForms into MVC and the biggest barrier to getting a responsive speed is the fact that, although reasonably well written, the logic layer assumed a stateful environment. The same application is being also re-written for WPF (another stateful environment) without so many issues.
Converting a desktop application to a web application has several challenges:
There are options to convert desktop applications in an automated way, these can convert both the UI and the code of the application:
Even when using automated migration tools, in most of the cases you will have to perform a significant amount of manual work to get the application working in the same way as the original one.
Some of these tools will help with different objectives, the first one will help you convert only the UI and to WebForms, the last two ones will generate ASP.NET MVC, one using a custom runtime and set of libraries and the other with common HTML/JS/CSS libraries such as Kendo MVVM, Kendo UI, AngularJS or Bootstrap among others. These tools will provide a solution that will be faster than writing the application in the web from scratch and will provide solutions or at least guidelines to approach the challenges mentioned before. However, there will be some differences from an application that was designed for the Web, simply because the architectures are different and usually the way of writing the code for a desktop application assumes thing that cannot be assumed for a web one.
Disclaimer: I work for Mobilize.Net, who built WebMAP2.
It's not something you can do automatically.
The trick is that in both winforms and webforms a form is represented by a plain old class. However, every time you handle an event for your form in asp.net webforms you're working with a brand new instance of the class. Microsoft went to a lot of trouble to try cover for this issue as much as possible, but in the end it's just not a good idea to think of a webform in the same terms as a winform.
So you can definitely take a winforms app and rewrite it to use webforms, but it will be just that: a rewrite.
Adding to previous answers, please note that there is some winform functionality that simply doesn't exist in a webform so it depends on exactly what's in the winform in the first place.