Click here to Skip to main content
15,909,656 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionLogin through HttpWebRequest? Pin
AliAmjad9-May-08 8:35
AliAmjad9-May-08 8:35 
I actually want to login to a web server on Local Area Network through HttpWebRequest Class, I am using the following code but can't seems to work...


<code>
        Dim wr As HttpWebRequest
        Dim wrs As HttpWebResponse


        wr = CType(WebRequest.Create("http://192.168.2.142/"), HttpWebRequest)
        wr.Method = "POST"

        Dim postData = "frmUserName=myUserName...&frmUserPass=myPassword..."
        wr.ContentLength = postData.Length
        wr.ContentType = "application/x-www-form-urlencoded"

        wr.AllowAutoRedirect = False

        Dim buffer() As Byte = System.Text.Encoding.ASCII.GetBytes(postData)

        Dim dataStrm As Stream = wr.GetRequestStream()
        dataStrm.Write(buffer, 0, buffer.Length)
        dataStrm.Close()

        Try

            wrs = wr.GetResponse

            Dim sr As New StreamReader(wrs.GetResponseStream)
            Me.rtxtData.Text = sr.ReadToEnd.ToString()
            sr.Close()

        Catch ex As Exception

            MsgBox(ex.ToString())

        End Try


</code>



Thanks in advance !



AliAmjad(MCP)


First make it Run THEN make it Run Fast!

AnswerRe: Login through HttpWebRequest? Pin
Dave Kreskowiak9-May-08 8:42
mveDave Kreskowiak9-May-08 8:42 
GeneralRe: Login through HttpWebRequest? Pin
AliAmjad9-May-08 9:44
AliAmjad9-May-08 9:44 
GeneralRe: Login through HttpWebRequest? Pin
Dave Kreskowiak9-May-08 9:56
mveDave Kreskowiak9-May-08 9:56 
GeneralRe: Login through HttpWebRequest? Pin
AliAmjad9-May-08 10:20
AliAmjad9-May-08 10:20 
GeneralRe: Login through HttpWebRequest? Pin
Dave Kreskowiak9-May-08 10:39
mveDave Kreskowiak9-May-08 10:39 
GeneralRe: Login through HttpWebRequest? Pin
AliAmjad9-May-08 22:35
AliAmjad9-May-08 22:35 
GeneralRe: Login through HttpWebRequest? Pin
Dave Kreskowiak10-May-08 5:49
mveDave Kreskowiak10-May-08 5:49 
GeneralRe: Login through HttpWebRequest? Pin
AliAmjad12-May-08 1:31
AliAmjad12-May-08 1:31 
QuestionCreating Button's Dynamicaly Pin
jacko8739-May-08 7:37
jacko8739-May-08 7:37 
AnswerRe: Creating Button's Dynamicaly Pin
Dave Kreskowiak9-May-08 7:48
mveDave Kreskowiak9-May-08 7:48 
GeneralRe: Creating Button's Dynamicaly [modified] Pin
jacko8739-May-08 8:02
jacko8739-May-08 8:02 
GeneralRe: Creating Button's Dynamicaly Pin
Dave Kreskowiak9-May-08 8:39
mveDave Kreskowiak9-May-08 8:39 
QuestionRe: Creating Button's Dynamicaly Pin
jacko8739-May-08 9:29
jacko8739-May-08 9:29 
AnswerRe: Creating Button's Dynamicaly Pin
Dave Kreskowiak9-May-08 9:57
mveDave Kreskowiak9-May-08 9:57 
GeneralRe: Creating Button's Dynamicaly Pin
jacko8739-May-08 10:13
jacko8739-May-08 10:13 
GeneralRe: Creating Button's Dynamicaly Pin
DanB19839-May-08 10:37
DanB19839-May-08 10:37 
GeneralRe: Creating Button's Dynamicaly Pin
Dave Kreskowiak9-May-08 10:41
mveDave Kreskowiak9-May-08 10:41 
QuestionVBA Help, probs really simple Pin
harveyhanson9-May-08 2:21
harveyhanson9-May-08 2:21 
AnswerRe: VBA Help, probs really simple Pin
parth.p9-May-08 2:56
parth.p9-May-08 2:56 
QuestionSelect subset of records from .xml Pin
cstrader2329-May-08 1:40
cstrader2329-May-08 1:40 
AnswerRe: Select subset of records from .xml Pin
Dave Kreskowiak9-May-08 3:27
mveDave Kreskowiak9-May-08 3:27 
GeneralRe: Select subset of records from .xml Pin
cstrader2329-May-08 6:07
cstrader2329-May-08 6:07 
GeneralRe: Select subset of records from .xml Pin
Dave Kreskowiak9-May-08 7:40
mveDave Kreskowiak9-May-08 7:40 
QuestionHelp with Linq in VB.net Pin
Chinners9-May-08 0:24
Chinners9-May-08 0:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.