your reference. .
"neerajb@noida.nospamhcltech.com" wrote:
> Hi Tønnessen,
>
> Thanks for the Reply!
> I have converted the code given by you in VB.NET and it is given below for
> your reference. .
>
> I am getting the error at the following line
> Dim streamOut As System.IO.Stream = request.GetRequestStream()
>
> also i am not getting the Ubyte datatype in VB.NET.
>
> am i missing something?
>
> Please help!!!!
>
> /*Code Starts */
> Dim request As System.Net.WebRequest =
> System.Net.WebRequest.Create("
https://corpmis.ggn.hcltech.com/")
>
> ' Post login
> request.Method = "POST"
> request.ContentType = "application/x-www-form-urlencoded"
> Dim streamOut As System.IO.Stream = request.GetRequestStream()
>
> Dim postMess As String = "Username=username&Password=#pass#123456789"
> Dim byt As Byte() = System.Text.Encoding.UTF8().GetBytes(postMess)
>
> streamOut.Write(byt, 0, byt.Length)
> streamOut.Close()
>
>
>
> ' Get the response stream
> Dim TheResponse As System.Net.WebResponse = request.GetResponse()
>
> ' Write the headers
> System.Console.WriteLine(TheResponse.Headers().ToString())
>
> ' Get the connection stream
> Dim stream As System.IO.Stream = TheResponse.GetResponseStream()
>
> ' Using a stream reader (to read a complete line etc)
> Dim sReader As System.IO.StreamReader = New
> System.IO.StreamReader(stream)
>
> 'Outputs all lines from the stream
> Dim line As String = ""
> 'While ((line = sReader.ReadLine()) <> null)
>
> ' System.Console.WriteLine(line)
> 'End While
>
> ' Close the connection
> TheResponse.Close()
>
> /* Code Ends */
> "Lars-Inge Tønnessen [VJ# MVP]" wrote:
>
> > > Hi Tønnessen ,
> >
> > Hello, :o)
> >
> >
> > > TheResponse.get_Headers().toString() as i am unnable to find any property
> > > by
> > > the name of get_headers and it's giving me error even on design time.
> >
> >
> > Maybe your using C# or VB.NET? Please try Headers().toString().
> > "get_" and "set_" is how J# is accessing .NET properites.
> >
> > System.Console.WriteLine( TheResponse.Headers().toString() );
> >
> > You can drop it you you want. It only prints out the http headers.
> >
> >
> > > Also do we need to pass any special parameters for HTTPS site or it is
> > > samefro both HTTP or HTTPS site.
> >
> >
> > Writing "https://" should do the trick for a secure connection.
> >
> >
> > > I am having valid username and password and trying to post the form.
> >
> > This sample code works for my web server. Please check the post id name in
> > the html source. I think its Username and Password on your site. Please
> > remeber to use a "&" between "Username=..." and "Password=...". Post it as
> > UTF8 and ubytes to the web server.
> >
> >
> > package httpconpost;
> >
> > public class Class1
> > {
> > public Class1()
> > {
> > // Open a https connection
> > System.Net.WebRequest request =
> > System.Net.WebRequest.Create("
https://corpmis.ggn.hcltech.com/");
> >
> > // Post login
> > request.set_Method( "POST" );
> > request.set_ContentType( "application/x-www-form-urlencoded" );
> > System.IO.Stream streamOut = request.GetRequestStream();
> >
> > String postMess = "Username=YourLoginName&Password=YourPassword";
> > ubyte byt[] = System.Text.Encoding.get_UTF8().GetBytes( postMess );
> >
> > streamOut.Write( byt, 0, byt.length );
> > streamOut.Close();
> >
> >
> >
> > // Get the response stream
> > System.Net.WebResponse TheResponse = request.GetResponse();
> >
> > // Write the headers
> > System.Console.WriteLine( TheResponse.get_Headers().toString() );
> >
> > // Get the connection stream
> > System.IO.Stream stream = TheResponse.GetResponseStream();
> >
> > // Using a stream reader (to read a complete line etc)
> > System.IO.StreamReader sReader = new System.IO.StreamReader( stream );
> >
> > // Outputs all lines from the stream
> > String line = "";
> > while ( (line = sReader.ReadLine()) != null )
> > {
> > System.Console.WriteLine( line );
> > }
> >
> > // Close the connection
> > TheResponse.Close();
> > }
> >
> > /** @attribute System.STAThread() */
> > public static void main(String[] args)
> > {
> > new Class1();
> > }
> > }
> >
> >
> > > Please HELP...........
> >
> > Did this help ?
> >
> >
> >
> > Best Regards,
> > Lars-Inge Tønnessen
> >
> >