Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to hit my URL from the below string but in log it cannot hit.

Dim myReq As HttpWebRequest
Dim httpURL As New System.Uri("http://10.10.113.73:8080/PaymentGateway/merchantTranVerification.jsp")

I also use  this code but not hit the URL.
Dim myReq As HttpWebRequest = WebRequest.Create("http://10.10.113.73:8080/PaymentGateway/merchantTranVerification.jsp")


Anybody give me httpwebrequest code for hitting the URL or any other alternate code for hitting URL.

please help me........
Posted
Updated 16-Sep-14 9:22am
v2

Please use this
Response.Redirect("http://10.10.113.73:8080/PaymentGateway/merchantTranVerification.jsp")
 
Share this answer
 
Just so you are aware, that you are using a local networking IP thus probably restricting you from accessing that file you are trying to ' hit ' it remotely. What do you mean by hit? Since i am not clear on what you want, I've provided you a C# example of StreamReader to read the file from a WebRequest. Let me know if this is what you want or not. Either way, it answers your question in the examples.

C#
C#
private void Main_Load(object sender, EventArgs e)
{
    WebRequest request = WebRequest.Create("http://10.10.113.73:8080/PaymentGateway/merchantTranVerification.jsp");
    request.Credentials = CredentialCache.DefaultCredentials;
    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    Stream iDataStream = response.GetResponseStream();
    StreamReader reader = new StreamReader(iDataStream);
    string eresponse = reader.ReadToEnd();
    MessageBox.Show(eresponse);
    reader.Close();
    iDataStream.Close();
    response.Close();
}

.Net
VB
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim inStream As StreamReader
    Dim webRequest As WebRequest
    Dim webresponse As WebResponse
    webRequest = webRequest.Create("http://10.10.113.73:8080/PaymentGateway/merchantTranVerification.jsp")
    webresponse = webRequest.GetResponse()
    inStream = New StreamReader(webresponse.GetResponseStream())
    Dim AvailCode As String = inStream.ReadToEnd()
    MsgBox("AvailCode: " + AvailCode)
End Sub
 
Share this answer
 
v2
Just creating a HttpWebRequest won't really do anything. You'll have to call GetResponse before something will happen:

MIDL
HttpWebResponse response = (HttpWebResponse)request.GetResponse();


As soon as GetResponse is called the server will be contacted.

Cheers!

-MRB
 
Share this answer
 
Comments
Afzaal Ahmad Zeeshan 16-Sep-14 12:01pm    
I assume the OP wants an answer in VB.NET and not C#.
[no name] 16-Sep-14 15:08pm    
Unless you are blind and stupid, I have provided both since he has both C# and VB.NET in his tags. Grow a brain please before submitting senseless babble. Thank you for your time.
Afzaal Ahmad Zeeshan 16-Sep-14 15:21pm    
And you should know that I have already upvoted your answer since that answers it. -_- Adding a tag doesn't categorize the post, using the code does. Look at the code he's having.
[no name] 16-Sep-14 15:31pm    
With respect Afzaal; I have read both. And the only reason I provided a C Sharp example is because he has a C# tag in his tags. Apologies if I came off harsh, I did also acknowledge his .NET example which is why I provided both.

Lol someone clearly stupid also down-voted my answer. Good man who ever you are. :)

Thank you for voting for my answer regardless. But you do need to look at the tags they use too. :)

Regards.
[no name] 16-Sep-14 18:59pm    
Why are the two of you fighting over a question that was asked and answered over 3 years ago? Do you really think that it matters anymore?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900