WebRequest.Create

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Thank you in advance for any and all assistance.

I'm trying to create a call to a web page to validate and register software.
The code I'm using is:

Private Sub OK_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles OK.Click
Dim WebRequest As HttpWebRequest
Dim instance As HttpWebRequest =
WebRequest.Create("https://www.plimus.com/jsp/validate...eTextBox.text&uniqueMachineId=GetOSProductKey")
End Sub

The error I'm getting is that .Error
1 'Create' is not a member of
'EZTechTools.LoginForm1.HttpWebRequest'. E:\EZTechToolsProMo\EZTechTools\LoginForm1.vb 119 42 EZTechToolsPro
HELP Please!
--
Michael Bragg, President
eSolTec, Inc.
a 501(C)(3) organization
MS Authorized MAR
looking for used laptops for developmentally disabled.
 
I'm trying to create a call to a web page to validate and register software.
The code I'm using is:

Private Sub OK_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles OK.Click
Dim WebRequest As HttpWebRequest
Dim instance As HttpWebRequest =
WebRequest.Create("https://www.plimus.com/jsp/validate...eTextBox.text&uniqueMachineId=GetOSProductKey")
End Sub

The error I'm getting is that .Error
1 'Create' is not a member of
'EZTechTools.LoginForm1.HttpWebRequest'. E:\EZTechToolsProMo\EZTechTools\LoginForm1.vb 119 42 EZTechToolsPro
HELP Please!

This looks like a name collision. There is in .net a shared method, namely
System.Net.WebRequest.Create
And you have a variable, WebRequest of type HttpWebRequest.
So, when you code WebRequest.Create, it sounds like you want the first and
not the second. If that is true, then change WebRequest.Create to
System.Net.WebRequest.Create. In any event, I suggest you change your
declaration
Dim WebRequest As HttpWebRequest
to a different name (ie change WebRequest to something else). It is poor
form to use a class name for a variable name. It is like coding
Dim String as Integer.
 
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles OK.Click
If Username.Text Is Nothing And License.Text Is Nothing Then
MessageBox.Show("Please enter your registered name.")
Username.Focus()
ElseIf Username.Text <> "" And License.Text Is Nothing Then
MessageBox.Show("Please enter your registration number:
###-####-####-####")
License.Focus()
Else
Dim myWebRequest As Net.WebRequest
Dim instance As Net.WebRequest =
Net.WebRequest.Create("https://www.plimus.com/jsp/validateKey.jsp?action=REGISTER&productId=#####&key="
+ "License.text" + "&uniqueMachineId=" + GetOSProductKey())
Dim response As Net.HttpWebResponse = request.GetResponse()
Dim reader As StreamReader = New
StreamReader(response.GetResponseStream())
Dim str As String = reader.ReadLine()
Do While str.Length > 0
str = str + reader.ReadLine()
Loop

End If
End Sub

now the error that I'm getting is:
Error 4 Name 'request' is not
declared. E:\EZTechToolsProMo\EZTechTools\frmRegistration.vb 122 51 EZTechToolsPro

Please someone help me fix this. I've been trying to get this resolved for
nearly three days now.


--
Michael Bragg, President
eSolTec, Inc.
a 501(C)(3) organization
MS Authorized MAR
looking for used laptops for developmentally disabled.
 
Hello Michael,

I think your code logic is absolute right. The error you encounter is
caused by some tiny syntax mistakes. e.g ,

The following statement in your code

Dim response As Net.HttpWebResponse = request.GetResponse()

should be changed to

Dim response As Net.HttpWebResponse = instance.GetResponse()

since you never declared a variable named "request".

Here is a complete code sinppet on using the webrequest to query a remote
http document:

===============================

Protected Sub btnRequest_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnRequest.Click

Dim request As Net.HttpWebRequest
Dim response As Net.HttpWebResponse

Dim url As String = "http://www.microsoft.com"

request = Net.WebRequest.Create(url)


request.Method = "Get"

'optional security setting
request.Credentials = Net.CredentialCache.DefaultCredentials

'optional proxy setting
request.Proxy = New Net.WebProxy("jpnproxy", 80)

response = request.GetResponse()

Dim sr As IO.StreamReader = New
IO.StreamReader(response.GetResponseStream())

Dim responseContent As String = sr.ReadToEnd()

sr.Close()
response.Close()

'content is in responseContent variable

End Sub
===================================

Here are some other web article describing using webrequest component to
access remote http document:

#Downloading Web Pages in VB.NET
http://www.vbdotnetheaven.com/Code/May2004/WebClassesVBNETMCB.asp

http://www.vbforums.com/archive/index.php/t-260654.html


Hope this helps some.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top