473,787 Members | 2,924 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

WebRequest.Crea te

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.EventArg s) Handles OK.Click
Dim WebRequest As HttpWebRequest
Dim instance As HttpWebRequest =
WebRequest.Crea te("https://www.plimus.com/jsp/validateKey.jsp ?action=REGISTE R&productId=### #&key=LicenseTe xtBox.text&uniq ueMachineId=Get OSProductKey")
End Sub

The error I'm getting is that .Error
1 'Create' is not a member of
'EZTechTools.Lo ginForm1.HttpWe bRequest'. E:\EZTechToolsP roMo\EZTechTool s\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.
Sep 6 '06 #1
3 9599
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.EventArg s) Handles OK.Click
Dim WebRequest As HttpWebRequest
Dim instance As HttpWebRequest =
WebRequest.Crea te("https://www.plimus.com/jsp/validateKey.jsp ?action=REGISTE R&productId=### #&key=LicenseTe xtBox.text&uniq ueMachineId=Get OSProductKey")
End Sub

The error I'm getting is that .Error
1 'Create' is not a member of
'EZTechTools.Lo ginForm1.HttpWe bRequest'. E:\EZTechToolsP roMo\EZTechTool s\LoginForm1.vb 119 42 EZTechToolsPro
HELP Please!
This looks like a name collision. There is in .net a shared method, namely
System.Net.WebR equest.Create
And you have a variable, WebRequest of type HttpWebRequest.
So, when you code WebRequest.Crea te, it sounds like you want the first and
not the second. If that is true, then change WebRequest.Crea te to
System.Net.WebR equest.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.

Sep 6 '06 #2
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As
System.EventArg s) 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=REGISTE R&productId=### ##&key="
+ "License.te xt" + "&uniqueMachine Id=" + GetOSProductKey ())
Dim response As Net.HttpWebResp onse = request.GetResp onse()
Dim reader As StreamReader = New
StreamReader(re sponse.GetRespo nseStream())
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:\EZTechToolsP roMo\EZTechTool s\frmRegistrati on.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.
"AMercer" wrote:
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.EventArg s) Handles OK.Click
Dim WebRequest As HttpWebRequest
Dim instance As HttpWebRequest =
WebRequest.Crea te("https://www.plimus.com/jsp/validateKey.jsp ?action=REGISTE R&productId=### #&key=LicenseTe xtBox.text&uniq ueMachineId=Get OSProductKey")
End Sub

The error I'm getting is that .Error
1 'Create' is not a member of
'EZTechTools.Lo ginForm1.HttpWe bRequest'. E:\EZTechToolsP roMo\EZTechTool s\LoginForm1.vb 119 42 EZTechToolsPro
HELP Please!

This looks like a name collision. There is in .net a shared method, namely
System.Net.WebR equest.Create
And you have a variable, WebRequest of type HttpWebRequest.
So, when you code WebRequest.Crea te, it sounds like you want the first and
not the second. If that is true, then change WebRequest.Crea te to
System.Net.WebR equest.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.
Sep 7 '06 #3
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.HttpWebResp onse = request.GetResp onse()

should be changed to

Dim response As Net.HttpWebResp onse = instance.GetRes ponse()

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_Clic k(ByVal sender As Object, ByVal e As
System.EventArg s) Handles btnRequest.Clic k

Dim request As Net.HttpWebRequ est
Dim response As Net.HttpWebResp onse

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

request = Net.WebRequest. Create(url)
request.Method = "Get"

'optional security setting
request.Credent ials = Net.CredentialC ache.DefaultCre dentials

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

response = request.GetResp onse()

Dim sr As IO.StreamReader = New
IO.StreamReader (response.GetRe sponseStream())

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/M...esVBNETMCB.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/subscripti...ult.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/subscripti...t/default.aspx.

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

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

Sep 7 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
6351
by: Paul | last post by:
Hello, First I want to refer to the problem "WebRequest : execute a button" of a few days ago. The way I solved it, I loose my session, and as a consequence my session variables. I don't want to keep those variables, as an alternative, as ViewState variables because I don't want to transfer to many hidden fields. This is the code I use :
8
2405
by: John K. | last post by:
Hi I was wondering if it's possible to use the WebRequest class to access a file on windows shared folder with authentication? If yes, what would the syntax be? I've tried to look this up in the references available but to no avail Also, is it safer (better practise) in an LAN environment to use HTTP requests to access shared files (via ASP.NET) rather than UNC file shares TIA Regards John
4
7235
by: Terry | last post by:
Hello, I am trying to get a response for an .aspx page in my current project (same virtual directory) by using WebRequest.GetResponse but I keep getting a exception with "500 Internal server error" in the exception message. I am able to do this fine with another .aspx page that has no code-behind. The page that has code-behind throws the exception. What I am doing is getting the .aspx response, reading the stream, replacing
12
2867
by: ThyRock | last post by:
I am working on a WebRequest accessing the US Postal Service WebTools test API. This service uses a DLL file (ShippingAPITest.dll) with a query string which includes XML. The web service accepts the query string with no url encoding. I must pass the <> characters as they are in the query string. If these characters are url encoded the service rejects the request. This API Url is http://testing.shippingapis.com/ShippingAPITest.dll
0
1805
by: jesper.hvid | last post by:
Hi. I've noticed, after moving some of our code to 2.0, that System.Net.WebRequest.Create(System.String) and System.Uri(System.String) no longer behave as they did in 1.1 framework. Example: string emailHttpPath =
1
4781
by: David Satz | last post by:
Hello--I just upgraded to Visual Studio .NET 2005 and suddenly, all my .NET 1.1 applications that accessed Web sites have broken. For example, this code: WebClient wc = new WebClient(); wc.DownloadFile("http://www.microsoft.com/", "MSFT.htm"); .... throws a WebException on the second line. The WebException doesn't specify a problem, but it has an InnerException of type NullReferenceException with the following stack trace:
4
1910
by: Sathyaish | last post by:
The WebRequest class implements IWebRequestCreate and hence, a method Create. This method has two other overloads, one of which is a private method. Here's how it looks: public static WebRequest Create(string requestUriString) public static WebRequest Create(Uri requestUri) private static WebRequest Create(Uri requestUri, bool useUriBase)
2
2969
by: Zytan | last post by:
I know that WebRequest.GetResponse can throw WebException from internet tutorials. However in the MSDN docs: http://msdn2.microsoft.com/en-us/library/system.net.webrequest.getresponse.aspx It only lists NotImplementedException in the Exceptions section. (Note that it does mention WebException in the Remarks section, but who knows if this is always the case for such classes, and thus perhaps they can't be trusted to always list these, and...
3
8188
by: Dave | last post by:
string m_request = some_web_page; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(m_request ); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Which works fine, but I need to set and send a cookie with the WebRequest. How do I do that?
0
9655
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10363
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10169
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4067
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.