title: VB.NET - Easiest way to Export / Convert WinForm App to Web ASP.NET App
body: <p>Background: I have a winform application written in VB.NET that uses a WebService to send out different invitations to users based on the marketing company they select to take different interviews. The winform app is pulling string values from a variety of textboxes, listboxes, and dropdownlists to create some XML and push it to a web service called AcompServiceClient</p>
  
  <p>Questions:</p>
  
  <ul>
  <li>Is there a wizard or 3rd party application that will export winform data to webform asp.net or should I build an aspx page from scratch w/ the same namespaces for all the controls as the winform app? </li>
  <li>Which files do I need to transport or setup to make this work besides the AcompServiceClient web service and the code-behind vb? (look at screenshot of the Project Files)</li>
  <li>Do i have to copy over any parts of the app.config file and adapt it to the web.config file?</li>
  </ul>
  
  <p>I was thinking:</p>
  
  <ul>
  <li>I can start by copying the Acomp_Invitation_Form.vb to the AComp_Invitation_Web_App.aspx.vb code behind page. </li>
  <li>Add existing webservice off the webserver   </li>
  <li>Manually re-add formatting, text boxes, list boxes, and drop down lists on the front end aspx page using the same names / id's</li>
  </ul>
  
  <p>Here's a screenshot of the WinForm App:  </p>
  
  <p><img src="https://i.stack.imgur.com/pWj0H.jpg" alt="ACOMP Screenshot"> </p>
  
  <p>Here's a screenshot of the Project Files:</p>
  
  <p><img src="https://i.stack.imgur.com/7z1Y2.jpg" alt="enter image description here"></p>
  
  <p>Here's my code on Acomp_Invitation_Form.vb:</p>
  
  <pre><code>Imports TestClient.aCompService
  Imports System.Text
  Public Class Form1
  
  Private proxy As New AcompServiceClient
  Private Sub stuff()
  
      Dim splitContractingBundle() As String
      splitContractingBundle = Split(cb2.SelectedItem, "|")
      Dim splitMarketingCompany() As String
      splitMarketingCompany = Split(cb3.SelectedItem, "|")
      Dim strDate As String = System.DateTime.Now.ToString
      Dim strOpData As String = String.Format("{0}~{1}~{2}~{3}~{4}~{5}~{6}~{7}~{8}~{9}~{10}",
                                              Trim(splitMarketingCompany(0)), txtFirstName.Text, "", txtLastName.Text,
                                              txtEmail.Text, txtEmail.Text, "1", strDate,
                                              "Pending", "1/1/1900", Trim(splitContractingBundle(0)))
  
      Dim int1 As Boolean = proxy.AddContractOpportunity(strOpData, "test", "test")
      txtEmail.Text = ""
      txtFirstName.Text = ""
      txtLastName.Text = ""
      lbCarriers.Items.Clear()
      cb2.Items.Clear()
      cb3.Items.Clear()
      cb2.SelectedItem = ""
      cb3.SelectedText = ""
  End Sub
  
  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  
      'TODO Add code to validate that all selections that are reaquired are met.
      'ccemail and the additional message are not required
      Dim firstname As String = txtFirstName.Text
      Dim lastname As String = txtLastName.Text
      Dim ccEmail As String = txtccEmail.Text
      Dim sb As New StringBuilder
      sb.AppendLine("&lt;?xml version=""1.0"" encoding=""utf-8""?&gt;")
      sb.AppendLine("&lt;root&gt;")
      sb.AppendLine("&lt;MarketingCompany&gt;")
      sb.AppendLine("&lt;MarketingCompanyName&gt;")
      ''Get Marketing Company Short Name
      Dim splitMC As String() = Split(cb3.SelectedItem, "|")
      Dim MCShort As String = Trim(splitMC(0))
      sb.AppendLine(String.Format("&lt;MCNAme&gt;{0}&lt;/MCNAme&gt;", MCShort))
      'sb.AppendLine(String.Format("&lt;MCNAme&gt;{0}&lt;/MCNAme&gt;", My.Settings.MarketingCompanyShortName))
      sb.AppendLine(String.Format("&lt;ccEmail&gt;{0}&lt;/ccEmail&gt;", txtccEmail.Text))
      sb.AppendLine(String.Format("&lt;emailMessage&gt;{0}&lt;/emailMessage&gt;", txtMessage.Text))
      sb.AppendLine(String.Format("&lt;MarketerName&gt;{0}&lt;/MarketerName&gt;", txtMarketerName.Text))
      sb.AppendLine("&lt;agent&gt;")
      sb.AppendLine(String.Format("&lt;FirstName&gt;{0}&lt;/FirstName&gt;", txtFirstName.Text))
      sb.AppendLine(String.Format("&lt;LastName&gt;{0}&lt;/LastName&gt;", txtLastName.Text))
      sb.AppendLine(String.Format("&lt;Email&gt;{0}&lt;/Email&gt;", txtEmail.Text))
      sb.AppendLine("&lt;CRMGuid&gt;123456&lt;/CRMGuid&gt;")
      Dim spltBundles() As String
  
      For Each item In cb2.SelectedItems
          If Trim(item) &lt;&gt; "" Then
              spltBundles = Split(item, "|")
              sb.AppendLine("&lt;ContractingOpportunity&gt;")
              sb.AppendLine(String.Format("&lt;Carrier&gt;{0}&lt;/Carrier&gt;", Trim(spltBundles(0))))
              sb.AppendLine(String.Format("&lt;ContractingOpportunityName&gt;{0}&lt;/ContractingOpportunityName&gt;", Trim(spltBundles(1))))
              sb.AppendLine("&lt;/ContractingOpportunity&gt;")
          End If
      Next
      sb.AppendLine("&lt;/agent&gt;")
      sb.AppendLine("&lt;/MarketingCompanyName&gt;")
      sb.AppendLine(" &lt;/MarketingCompany&gt;")
      sb.AppendLine(" &lt;/root&gt;")
      Dim xmlStr = sb.ToString
      Dim int1 As Boolean = proxy.AddContractOpportunity(xmlStr.ToString, "test", "test")
      MsgBox("Made It")
  End Sub
  
  Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
      GetCarriers()
      GetMarketingCompanies()
  End Sub
  
  Private Sub GetCarriers()
      Try
          Dim ac1 As Array
          ac1 = proxy.GetCarrierNames("test", "test")
  
          For Each item In ac1
              lbCarriers.Items.Add(String.Format("{0} | {1} | {2}", item.CarrierID, item.CarrierNameLong, item.CarrierNameShort))
  
          Next
      Catch ex As Exception
          MsgBox(ex.Message)
      End Try
  
  End Sub
  Private Sub GetMarketingCompanies()
      Try
          Dim ac1 As Array
          ac1 = proxy.GetMarketingCompanyNames("test", "test")
  
          For Each item In ac1
              cb3.Items.Add(String.Format("{0}   |   {1}", item.MarketingCompanyShort, item.MarketingCompanyName))
          Next
      Catch ex As Exception
          MsgBox(ex.Message)
      End Try
  End Sub
  
  Private Sub lbCarriers_LostFocus(sender As Object, e As System.EventArgs) Handles lbCarriers.LostFocus
      Dim splt() As String
      Dim ac1 As Array
      cb2.Items.Clear()
  
      For Each item In lbCarriers.SelectedItems
          splt = Split(item, "|")
          ac1 = proxy.GetContractingBundles("test", "test", Trim(splt(0)))
          For Each Pitem In ac1
              cb2.Items.Add(Trim(splt(2)) &amp; " | " &amp; Pitem.FormBundleName)
          Next
      Next
  End Sub
  End Class
  </code></pre>