Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to enable proxy ip address and port with credentials
VB
Dim res As String = String.Empty
       Try


           res = apicall("http://........................................")
       Catch ex As Exception
       End Try


       If Not res.StartsWith("Wrong Username or Password") Then

           Return True
       Else
           'message not sent successfully................
           Return False
       End If

   End Function

   Public Function apicall(ByVal url As String) As String
       Dim httpreq As HttpWebRequest = DirectCast(WebRequest.Create(url), HttpWebRequest)
       Try
           Dim httpres As HttpWebResponse = DirectCast(httpreq.GetResponse(), HttpWebResponse)
           Dim sr As New StreamReader(httpres.GetResponseStream())
           Dim results As String = sr.ReadToEnd()
           sr.Close()
           Return results
       Catch ex As Exception
           Return "0"
       End Try

   End Function
Posted
Updated 8-May-12 20:29pm
v6
Comments
walterhevedeich 9-May-12 2:19am    
Is there an error on the code? I think I'm missing the real question here.
mani.kishore.asp.net 9-May-12 2:27am    
trying to include the proxy but does not work

Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Data
Imports System.Configuration
Imports System.Xml.Linq
Imports System.Net
Imports System.Net.Mail
Imports System.Data.SqlClient
Imports System.IO
Imports System.Globalization

'''
''' Summary description for smsapi
'''

Public Class smsapi

Public Function SendEnglishSMS(ByVal mobilno As String, ByVal msgcontent As String) As Boolean


Dim res As String = String.Empty
Try

res = apicall("http://............................................")
Catch ex As Exception
End Try


If Not res.StartsWith("Wrong Username or Password") Then

Return True
Else
'message not sent successfully................
Return False
End If

End Function

Public Function apicall(ByVal url As String) As String


Dim httpreq As HttpWebRequest = DirectCast(WebRequest.Create(url), HttpWebRequest)
Try

Dim myProxy As New Net.WebProxy("ip address", 80)
myProxy.BypassProxyOnLocal = True
myProxy.Credentials = New NetworkCredential("username", "password")
httpreq.Proxy = myProxy


Dim httpres As HttpWebResponse = DirectCast(httpreq.GetResponse(), HttpWebResponse)

Dim sr As New StreamReader(httpres.GetResponseStream())




Dim results As String = sr.ReadToEnd()
sr.Close()
Return results
Catch ex As Exception
Return "0"
End Try

End Function
End Class

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