user3352250
user3352250

Reputation: 326

Porting WPF to ASP MVC?

We are developing an application that is going to have a Desktop WPF app and a web-face on ASP MVC. My main question is, what is the way to go to make the work as less repetitive as possible.

My ideal is developing the WPF app in someway using the MVC pattern, so that we could just copy/paste the controllers from the WPF app to ASP and work only on the View part. Is that possible?

I have researched and found that for that kind of tasks I could also stick on to using XBAP, but, as far as we have researched, many people are having problems with launching them. Silverlight is also not a way to go :(

Any ideas?

Thanks for your time!

Upvotes: 1

Views: 2565

Answers (3)

Fede
Fede

Reputation: 44038

No, you can't "copy/paste" stuff from a Windows application to a Web Application. And no. "copy/paste" is not an optimal way of reuse.

You're going about this in a completely wrong way.

The main idea behind Reusability is to keep application components and layers decoupled from each other so that they can be ported to different applications or even different platforms.

There's no way you are going to share Presentation code between a Web and a Windows application (regardless of the underlying UI frameworks on each side) simply because the HTML-based Web UI is stateless in nature and a Windows application is usually developed in a stateful way.

What you need to do is to use MVVM in the WPF side (as opposed to MVC) in order to keep the application logic and most importantly the Business Logic completely decoupled from the UI.

This way there will be a much greater opportunity for reuse in any other platform. All your shared Business Logic and application logic will live in UI-agnostic layers which don't really "care" about the Front-End.

Upvotes: 3

ken2k
ken2k

Reputation: 48985

I would advice to forget the idea of reusing large pieces of client code.

What I would recommend is to build a 3-tier architecture, so you could reuse all the service layers (business services and DAL) in both ASP.Net MVC and WPF applications. You'll still have to code a lot of specific code in each application.

If your main goal is to deploy a WPF application through the Internet, then XBAP is the way to go. Or Silverlight, as it's a mature technology that'll be supported for years.

Upvotes: 1

vidalsasoon
vidalsasoon

Reputation: 4401

Not possible. WPF and ASP.NET MVC have totally different Views.

Only thing you could re-use is your back-end API. Instead of injecting your API classes into your ViewModels like you would with WPF, you would be injecting those same API classes into your MVC controllers.

Upvotes: 1

Related Questions