views:

170

answers:

6

I have a pretty basic windows form app in .Net. All the code is C#. I'd like to turn it into an Asp.net web app. How can I easily do this?

I think there's an easy way since the controls I drag/drop onto the windows form designer are pretty much the same that I drag/drop onto the aspx design page.

Note: the windows form app doesn't make any network requests or anything... just reads some text files from the local machine.

Thanks!

+1  A: 

The interface is going to have to change, as the controls are different. If you have supporting business classes, and other items of that nature you can copy those over, but otherwise the UI will need to be re-built.

Mitchel Sellers
+2  A: 

You'll likely have issues reading files from the local machine via ASP.Net: for an ASP.Net app, the local machine is the web server, not the computer where the user is sitting.

Also, there's a lot more to it than you'd think. odds are somewhere in your app you're relying on the fact the a windows forms app is inherently stateful, and moving to ASP.Net will be a rude awakening in that respect.

Joel Coehoorn
+4  A: 

There are two big problems here; first - they might look the same, but they are implemented completely differently - all of the UI work will need to be redone, largely from scratch. You will probably be able to re-use your actual "doing" code, though (i.e. the logic that manipulates the files).

Second - define "local machine". For an ASP.NET application, this is usually the server, which might not be what you want. You can do some things clientside via javascript, but the sandbox security model will prevent you doing much file IO.

I would suggest perhaps looking at Silverlight, which is somewhere between the two - or perhaps just use ClickOnce to deploy your existing winform exe to remote clients.

Marc Gravell
+1  A: 

ASP.NET and Windows Forms are 2 completely different models. Yes, the designers are similar, but the underlying representation of the page/form is different. The major difference is that ASP.NET is stateless, so you have to adjust your method of storing data in between operations and push it to the Session object.

For local apps that only you will use, my recommendation is to stick with Windows Forms.

Jason Z
+1  A: 

That would really depend on how the app is designed. If you have all the "business logic" of the app in the Windows Forms then you will have a difficult time converting it over. If the logic is in it's own layer it will be much easier. Please realize there are a lot of differences between Windows and Web Forms; one of the largest is that web forms are disconnected from the user and state information is sent with each request. Winforms are certainly more full featured.

Brettski
+1  A: 

Unfortunately, it is not going to be that simple. Your C# code and logic will transfer over easily, but the WinForms UI is completely different from ASP.NET UI.

If you are interested in a "web application" that can be designed using the same kind of non-HTML GUI designer as your existing C# app, look at Microsoft Silverlight. It is designed to be a version of the new Windows Presentation Foundation (WPF, the successor to WinForms) for the web.

amdfan