none
Convert C# windows form application to ASP.NET

    Question

  • I have created an C# window form application from Micosoft Visual Studio 2010.

    When I try to put this into ASP.NET invironmont, it is very frustrated working for me.

    I have no idea how to do.

    I think .csproj file would to for converting my code to ASP.NET or

    at least import the window form application working on ASP.NET form.

    Could anyone please answer this question who has very variety experience on similar sort of problem?

    Thank you!

    I can be also working on 2012, if the special feature on 2012 would help for this problem.

    Monday, April 29, 2013 11:09 AM

Answers

  • The windows form and the web form are really different about the structure. So we have to be care about some thing like Session, ViewState, Security, rendering the View, Http model...

    Please see the comparison from Microsoft here and link here


    Simple is better...

    Monday, April 29, 2013 12:29 PM
  • Go back to your Windows Forms application and try to rewrite it so that all of the code in the Form classes only  contain code that directly updates the UI display in event handlers.  Other code in the Form classes should react to user actions and fire events.  It is critical that Form classes do not process any of the data.  This requires using events to pass data between classes: one to display data; one to pass data; and separate ones to process and access data;

    You may want to look at how the Model-View-Controller pattern works.  I once posted a boiled down version of the MVC pattern in WinForms in the Windows Forms Forum. 

    http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/3E5B7DB2-7F7F-4232-8E15-3D5F2CA2827F  

    There is a link in that thread to the sample.  I gave a layman's explanation of how the pattern works, and why it performs its' work in such a seemingly round about fashion.

    Once you have separated your business logic from your UI logic, the task of converting the application to use another type of UI should be much simpler.

    Hope this helps.

    Rudy


    Mark the best replies as answers. "Fooling computers since 1971."

    http://thesharpercoder.com/

    Monday, April 29, 2013 1:30 PM
  • If you want to have single code to run on Web and Windows both environment following are alternatives.

    1. Create Windows Store App  using HTML related Technology (Recommended Solution)

    2. Create XAML(WPF & Sliverlight) App (http://msdn.microsoft.com/en-us/library/windows/apps/jj129462.aspx) (Not recommended)

    3. Make changes in your application architecture (Highly Recommended Solution)

             3.1 Create a separate library project to contain Business logic (having No UI related stuff)

             3.2 Create a WinForm App for Windows App using the same Business Logic library created in Step 1

             3.3 Create ASP.NET app reusing the same Business Logic Library created in Step 1


    Faisal Ahmed Farooqui

    Monday, April 29, 2013 11:57 AM

All replies

  • Hi,

    A Windows Forms and a Web application are based on very different technologies so the port will require a massive rewriting work (and if you are not familiar with web dev, you'll have also quite a few things to learn).

    Either distributing the application using a website is enough and you could look at ClickOnce (that allows to install a Windows Forms app from a web site) or you really want to port and you'll have to rewrite the UI part (a start could be to change the Windows application if needed to clearly separated the UI part you'll need to rewrite and other parts you could more easily reuse if any).

    Another option could be to use remote desktop so that remote users can connect to a server machine and use it...

    Ensure also that your app does nothing that couldn't be done using a web app (for example accessing local resources such as files etc...).

    See http://www.asp.net/get-started if needed to give a look at how a web dev is done...


    Please always mark whatever response solved your issue so that the thread is properly marked as "Answered".


    Monday, April 29, 2013 11:37 AM
  • If you want to have single code to run on Web and Windows both environment following are alternatives.

    1. Create Windows Store App  using HTML related Technology (Recommended Solution)

    2. Create XAML(WPF & Sliverlight) App (http://msdn.microsoft.com/en-us/library/windows/apps/jj129462.aspx) (Not recommended)

    3. Make changes in your application architecture (Highly Recommended Solution)

             3.1 Create a separate library project to contain Business logic (having No UI related stuff)

             3.2 Create a WinForm App for Windows App using the same Business Logic library created in Step 1

             3.3 Create ASP.NET app reusing the same Business Logic Library created in Step 1


    Faisal Ahmed Farooqui

    Monday, April 29, 2013 11:57 AM
  • The windows form and the web form are really different about the structure. So we have to be care about some thing like Session, ViewState, Security, rendering the View, Http model...

    Please see the comparison from Microsoft here and link here


    Simple is better...

    Monday, April 29, 2013 12:29 PM
  • Go back to your Windows Forms application and try to rewrite it so that all of the code in the Form classes only  contain code that directly updates the UI display in event handlers.  Other code in the Form classes should react to user actions and fire events.  It is critical that Form classes do not process any of the data.  This requires using events to pass data between classes: one to display data; one to pass data; and separate ones to process and access data;

    You may want to look at how the Model-View-Controller pattern works.  I once posted a boiled down version of the MVC pattern in WinForms in the Windows Forms Forum. 

    http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/3E5B7DB2-7F7F-4232-8E15-3D5F2CA2827F  

    There is a link in that thread to the sample.  I gave a layman's explanation of how the pattern works, and why it performs its' work in such a seemingly round about fashion.

    Once you have separated your business logic from your UI logic, the task of converting the application to use another type of UI should be much simpler.

    Hope this helps.

    Rudy


    Mark the best replies as answers. "Fooling computers since 1971."

    http://thesharpercoder.com/

    Monday, April 29, 2013 1:30 PM