TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Arun Raheja
NA
1
1.1k
Error in Calling HTTP Api in .net Framework
Nov 2 2014 11:29 PM
The underlying connection was closed: An unexpected error occurred on a send.
I am getting Above Error when i run that code on the server.
========================================================
Dim response As String = String.Empty
Dim MyRetVal As String = "Invalid"
Dim requestTOService As System.Net.HttpWebRequest
Dim auth_userid As Int64 = 377686
Dim api_key As String = "AdvY0zXBg9hNnqqXXuaPZLEXfIcDYUCb"
Try
System.Net.ServicePointManager.ServerCertificateValidationCallback = (Function(sender, certificate, chain, sslPolicyErrors) True)
ServicePointManager.MaxServicePointIdleTime = 1000
ServicePointManager.UseNagleAlgorithm = True
ServicePointManager.Expect100Continue = True
ServicePointManager.CheckCertificateRevocationList = True
ServicePointManager.DefaultConnectionLimit = _
ServicePointManager.DefaultPersistentConnectionLimit
requestTOService = System.Net.HttpWebRequest.Create("https://httpapi.com/api/domains/available.xml?auth-userid=" + auth_userid.ToString() + "&api-key=" + api_key + "&domain-name=" + MyDomain + "&tlds=" + tld)
requestTOService.Method = System.Net.WebRequestMethods.Http.Get
requestTOService.ContentType = "application/x-www-form-urlencoded"
requestTOService.KeepAlive = False
Dim responseFromService As System.Net.HttpWebResponse
responseFromService = CType(requestTOService.GetResponse(), System.Net.HttpWebResponse)
Dim readResponse As New System.IO.StreamReader(responseFromService.GetResponseStream())
response = readResponse.ReadToEnd
'ReadResponse
If response.Contains("available") Or response.Contains("Available") Then
MyRetVal = "available"
End If
Catch ex As WebException
If ex.Response IsNot Nothing Then
Dim httpwebres As System.Net.HttpWebResponse = ex.Response
Dim respSteam As New StreamReader(httpwebres.GetResponseStream())
End If
End Try
========================================================
Reply
Answers (
1
)
Console Application
Web application performance