I Want to my Application Open URL in default browser in WinForm Application. And Then Send Some data as HTTP POST method not as query string. now the problem is if i want to open URL in default browser i used this code:
Process.Start("http://www.ketabchin.com/sort)
But in this command i can not send post data to that url Then i Used this code :
Public Shared Function PostMessageToURL(url As String) As String
Dim request As WebRequest = WebRequest.Create("https://www.ketabchin.com/windows-logged")
request.Method = "POST"
Dim postData As String = "u=" & FrmMain.Username & "&p=" & FrmMain.Password & "&url=" & url
Dim byteArray As Byte() = Encoding.UTF8.GetBytes(postData)
request.ContentType = "application/x-www-form-urlencoded"
request.ContentLength = byteArray.Length
Dim dataStream As Stream = request.GetRequestStream()
dataStream.Write(byteArray, 0, byteArray.Length)
dataStream.Close()
Dim response As WebResponse = request.GetResponse()
Console.WriteLine(CType(response, HttpWebResponse).StatusDescription)
dataStream = response.GetResponseStream()
Dim reader As New StreamReader(dataStream)
Dim responseFromServer As String = reader.ReadToEnd()
reader.Close()
dataStream.Close()
response.Close()
Return responseFromServer
End Function
This one Send the HTTP POST request data to url but i can not open it or the response in default web browser. how can i do this? The logic of behind this action is. i have a WinForm Application and when my user click on "goto website" buttton in my application . i want to open the browser and send logging data to the login page, so the user can visit the site in Logging mode.