I'm trying to convert a previously written .net winform app from vb to c# and I'm running into trouble with a web send function. How can I convert this into c#?
Public Shared Function Send(p_ipAddress As String, p_action As String, p_page As String, p_body As String, p_filePath As String) As String
Dim objHttp = CreateObject("MSXML2.ServerXMLHTTP")
'objHttp.setTimeouts(1000, 1000, 1000, 1000) '-- Timeout
objHttp.Open(p_action, sUrl, False)
If t_fileContent.Length > 0 Then
objHttp.setRequestHeader("Content-Type", "multipart/form-data; boundary=" & t_multipart_boundary)
Else
t_fileContent.Append(p_body)
objHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
End If
objHttp.Send(t_fileContent.ToString())
If objHttp.Status = 200 Then
Return objHttp.responseText
End If
Return ""
End Function
The HTTP object is what I'm having trouble translating into c#. I dont' know whether I need to use a http client, http web request, I'm fairly new to web calls.
EDIT I've shortened the code to specifically what I'm not sure about, removing the fluff.