title: Web application to legacy code interop
body: <p>I am trying to migrate a simple WinForms app to a ASP.Net web app. WinForms app is basically only a presentation layer for a complex plain C app, and interacts with legacy code through COM interop. I have modest experience in ASP.Net, javascript, jQuery, and lots of experience in WinForms and interop, so I know the basics, I just need to make a design decision.</p>
  
  <p>The way the app looks right now is this:</p>
  
  <ol>
  <li><p>There is a bunch of legacy C (not even C++) code which <strong>can</strong> be changed and recompiled, but porting is not an option. This is the business+data layer, call it what you want. I'll refer to it as <strong>legacy code</strong>.</p></li>
  <li><p>When started, legacy code instantiates a COM server which is used for presentation and user interaction. Presentation data is serialized and sent to this COM object (<strong>"I'm sending you some output."</strong>), and user interaction is achieved through cyclic polling (<strong>"Do you have some input for me?"</strong>). Not the prettiest solution but simple as hell.</p></li>
  <li><p>COM object is actually a .NET 2.0 WinForms app exposed as COM. This app also exposes some functionality to other .NET apps through .NET Remoting, but that is not so important also.</p></li>
  </ol>
  
  <p>Although the system is rather complicated, WinForms app is really used for interaction only, so it's pretty easy to switch to web. What I am not sure is what's the best way to do the web server &lt;---> legacy code interaction.</p>
  
  <p>The first thing that comes to my mind (since I already have .NET Remoting implemented) is to expose the WinForms functionality to the Web part through local .NET Remoting, making it act like some sort of a proxy between legacy code and web app. I would actually only need the communication part, without forms. In that case, web app would have to access this functionality through .NET Remoting (locally).</p>
  
  <p>Is it wise to have web app communicate locally to another app using .NET Remoting? Also, I could change the app to a Windows service, but would I still be able to expose its functionality through COM to legacy code?</p>
  
  <p>What would be a better way to achieve this? Note that I can also make some modifications to the legacy code if needed.</p>