Alex Rivera | Logout

Is it possible to convert a WinForm to a WebForm in .NET?

Asked 2010-12-07T16:39:47.650
12

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?

Edit
Report

1 Answer

11

It's not something you can do automatically.

The trick is both Winforms and Webforms represent a form using a plain old class. However, instances of the class in Webforms are short-lived compared to Winforms; each Webforms class instance represents only one HTTP request, rather than the entire lifetime of the form, as with Winforms. 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.

You can definitely take a Winforms app and rewrite it to use Webforms, but it will be just that: a rewrite.

answered 2010-12-07T16:43:10.870

Your Answer