Reading the text from a text file on a web server [duplicate]
This question already has an answer here:
Make Https call using HttpClient
10 answers
I used to be able to read a text file located on our public web server, into a string variable. Something has changed on the web server and now my function does not work anymore. The text file is still there and can be opened using a web browser but I cannot read it from my VB.net application
Here is the link to a sample text file: https://www.mgfx.co.za/license.txt
Dim http As New Net.Http.HttpClient
Dim strWebString As String = Await http.GetStringAsync(New Uri("https://www.mgfx.co.za/license.txt"))
This does not work anymore and throws an error about authentication. "IOException: Authentication failed because the remote party has closed the transport stream."
I can only imagine that our hosting provider has implemented some sort of new security measures which now block calls from my app.
Can anyone help here or know why this is the case?
vb.net
marked as duplicate by Ahmed Abdelhameed, Community♦ Nov 27 '18 at 20:36
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Make Https call using HttpClient
10 answers
I used to be able to read a text file located on our public web server, into a string variable. Something has changed on the web server and now my function does not work anymore. The text file is still there and can be opened using a web browser but I cannot read it from my VB.net application
Here is the link to a sample text file: https://www.mgfx.co.za/license.txt
Dim http As New Net.Http.HttpClient
Dim strWebString As String = Await http.GetStringAsync(New Uri("https://www.mgfx.co.za/license.txt"))
This does not work anymore and throws an error about authentication. "IOException: Authentication failed because the remote party has closed the transport stream."
I can only imagine that our hosting provider has implemented some sort of new security measures which now block calls from my app.
Can anyone help here or know why this is the case?
vb.net
marked as duplicate by Ahmed Abdelhameed, Community♦ Nov 27 '18 at 20:36
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
1
May want to check that you're using TLS 1.2, not the default 1.1...a lot of web servers are requiring that now and I've been dealing with programs erroring because of that all year
– soohoonigan
Nov 27 '18 at 19:58
Just add this line before sending the request for the first time:ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 Or SecurityProtocolType.Tls11 Or SecurityProtocolType.Tls
.
– Ahmed Abdelhameed
Nov 27 '18 at 20:00
It's really strange but the code works for me pretty well:Using client As New HttpClient : Dim x = Await client.GetStringAsync(New Uri("https://www.mgfx.co.za/license.txt")) : End Using
– JohnyL
Nov 27 '18 at 20:16
Thanks guys! The TLS 1.2 setting seems to have solved it.
– Raider_007
Nov 27 '18 at 20:27
@JohnyL Maybe, you have something like this:<appSettings><add key="SecurityProtocol" value="3072" /></appSettings>
or this:<add key="SecurityProtocol" value="Tls12" />
in yourapp.config
file. There's also a registry value that can set this protocol as the default. Some applications, it happens, do this behind your back. Some developers think it's all OK, then they deploy and...
– Jimi
Nov 27 '18 at 20:50
add a comment |
This question already has an answer here:
Make Https call using HttpClient
10 answers
I used to be able to read a text file located on our public web server, into a string variable. Something has changed on the web server and now my function does not work anymore. The text file is still there and can be opened using a web browser but I cannot read it from my VB.net application
Here is the link to a sample text file: https://www.mgfx.co.za/license.txt
Dim http As New Net.Http.HttpClient
Dim strWebString As String = Await http.GetStringAsync(New Uri("https://www.mgfx.co.za/license.txt"))
This does not work anymore and throws an error about authentication. "IOException: Authentication failed because the remote party has closed the transport stream."
I can only imagine that our hosting provider has implemented some sort of new security measures which now block calls from my app.
Can anyone help here or know why this is the case?
vb.net
This question already has an answer here:
Make Https call using HttpClient
10 answers
I used to be able to read a text file located on our public web server, into a string variable. Something has changed on the web server and now my function does not work anymore. The text file is still there and can be opened using a web browser but I cannot read it from my VB.net application
Here is the link to a sample text file: https://www.mgfx.co.za/license.txt
Dim http As New Net.Http.HttpClient
Dim strWebString As String = Await http.GetStringAsync(New Uri("https://www.mgfx.co.za/license.txt"))
This does not work anymore and throws an error about authentication. "IOException: Authentication failed because the remote party has closed the transport stream."
I can only imagine that our hosting provider has implemented some sort of new security measures which now block calls from my app.
Can anyone help here or know why this is the case?
This question already has an answer here:
Make Https call using HttpClient
10 answers
vb.net
vb.net
asked Nov 27 '18 at 19:50
Raider_007Raider_007
92
92
marked as duplicate by Ahmed Abdelhameed, Community♦ Nov 27 '18 at 20:36
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Ahmed Abdelhameed, Community♦ Nov 27 '18 at 20:36
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
1
May want to check that you're using TLS 1.2, not the default 1.1...a lot of web servers are requiring that now and I've been dealing with programs erroring because of that all year
– soohoonigan
Nov 27 '18 at 19:58
Just add this line before sending the request for the first time:ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 Or SecurityProtocolType.Tls11 Or SecurityProtocolType.Tls
.
– Ahmed Abdelhameed
Nov 27 '18 at 20:00
It's really strange but the code works for me pretty well:Using client As New HttpClient : Dim x = Await client.GetStringAsync(New Uri("https://www.mgfx.co.za/license.txt")) : End Using
– JohnyL
Nov 27 '18 at 20:16
Thanks guys! The TLS 1.2 setting seems to have solved it.
– Raider_007
Nov 27 '18 at 20:27
@JohnyL Maybe, you have something like this:<appSettings><add key="SecurityProtocol" value="3072" /></appSettings>
or this:<add key="SecurityProtocol" value="Tls12" />
in yourapp.config
file. There's also a registry value that can set this protocol as the default. Some applications, it happens, do this behind your back. Some developers think it's all OK, then they deploy and...
– Jimi
Nov 27 '18 at 20:50
add a comment |
1
May want to check that you're using TLS 1.2, not the default 1.1...a lot of web servers are requiring that now and I've been dealing with programs erroring because of that all year
– soohoonigan
Nov 27 '18 at 19:58
Just add this line before sending the request for the first time:ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 Or SecurityProtocolType.Tls11 Or SecurityProtocolType.Tls
.
– Ahmed Abdelhameed
Nov 27 '18 at 20:00
It's really strange but the code works for me pretty well:Using client As New HttpClient : Dim x = Await client.GetStringAsync(New Uri("https://www.mgfx.co.za/license.txt")) : End Using
– JohnyL
Nov 27 '18 at 20:16
Thanks guys! The TLS 1.2 setting seems to have solved it.
– Raider_007
Nov 27 '18 at 20:27
@JohnyL Maybe, you have something like this:<appSettings><add key="SecurityProtocol" value="3072" /></appSettings>
or this:<add key="SecurityProtocol" value="Tls12" />
in yourapp.config
file. There's also a registry value that can set this protocol as the default. Some applications, it happens, do this behind your back. Some developers think it's all OK, then they deploy and...
– Jimi
Nov 27 '18 at 20:50
1
1
May want to check that you're using TLS 1.2, not the default 1.1...a lot of web servers are requiring that now and I've been dealing with programs erroring because of that all year
– soohoonigan
Nov 27 '18 at 19:58
May want to check that you're using TLS 1.2, not the default 1.1...a lot of web servers are requiring that now and I've been dealing with programs erroring because of that all year
– soohoonigan
Nov 27 '18 at 19:58
Just add this line before sending the request for the first time:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 Or SecurityProtocolType.Tls11 Or SecurityProtocolType.Tls
.– Ahmed Abdelhameed
Nov 27 '18 at 20:00
Just add this line before sending the request for the first time:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 Or SecurityProtocolType.Tls11 Or SecurityProtocolType.Tls
.– Ahmed Abdelhameed
Nov 27 '18 at 20:00
It's really strange but the code works for me pretty well:
Using client As New HttpClient : Dim x = Await client.GetStringAsync(New Uri("https://www.mgfx.co.za/license.txt")) : End Using
– JohnyL
Nov 27 '18 at 20:16
It's really strange but the code works for me pretty well:
Using client As New HttpClient : Dim x = Await client.GetStringAsync(New Uri("https://www.mgfx.co.za/license.txt")) : End Using
– JohnyL
Nov 27 '18 at 20:16
Thanks guys! The TLS 1.2 setting seems to have solved it.
– Raider_007
Nov 27 '18 at 20:27
Thanks guys! The TLS 1.2 setting seems to have solved it.
– Raider_007
Nov 27 '18 at 20:27
@JohnyL Maybe, you have something like this:
<appSettings><add key="SecurityProtocol" value="3072" /></appSettings>
or this: <add key="SecurityProtocol" value="Tls12" />
in your app.config
file. There's also a registry value that can set this protocol as the default. Some applications, it happens, do this behind your back. Some developers think it's all OK, then they deploy and...– Jimi
Nov 27 '18 at 20:50
@JohnyL Maybe, you have something like this:
<appSettings><add key="SecurityProtocol" value="3072" /></appSettings>
or this: <add key="SecurityProtocol" value="Tls12" />
in your app.config
file. There's also a registry value that can set this protocol as the default. Some applications, it happens, do this behind your back. Some developers think it's all OK, then they deploy and...– Jimi
Nov 27 '18 at 20:50
add a comment |
1 Answer
1
active
oldest
votes
Adding this to my code fixed the issue.
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 Or SecurityProtocolType.Tls11 Or SecurityProtocolType.Tls
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Adding this to my code fixed the issue.
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 Or SecurityProtocolType.Tls11 Or SecurityProtocolType.Tls
add a comment |
Adding this to my code fixed the issue.
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 Or SecurityProtocolType.Tls11 Or SecurityProtocolType.Tls
add a comment |
Adding this to my code fixed the issue.
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 Or SecurityProtocolType.Tls11 Or SecurityProtocolType.Tls
Adding this to my code fixed the issue.
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 Or SecurityProtocolType.Tls11 Or SecurityProtocolType.Tls
answered Nov 27 '18 at 20:34
Raider_007Raider_007
92
92
add a comment |
add a comment |
1
May want to check that you're using TLS 1.2, not the default 1.1...a lot of web servers are requiring that now and I've been dealing with programs erroring because of that all year
– soohoonigan
Nov 27 '18 at 19:58
Just add this line before sending the request for the first time:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 Or SecurityProtocolType.Tls11 Or SecurityProtocolType.Tls
.– Ahmed Abdelhameed
Nov 27 '18 at 20:00
It's really strange but the code works for me pretty well:
Using client As New HttpClient : Dim x = Await client.GetStringAsync(New Uri("https://www.mgfx.co.za/license.txt")) : End Using
– JohnyL
Nov 27 '18 at 20:16
Thanks guys! The TLS 1.2 setting seems to have solved it.
– Raider_007
Nov 27 '18 at 20:27
@JohnyL Maybe, you have something like this:
<appSettings><add key="SecurityProtocol" value="3072" /></appSettings>
or this:<add key="SecurityProtocol" value="Tls12" />
in yourapp.config
file. There's also a registry value that can set this protocol as the default. Some applications, it happens, do this behind your back. Some developers think it's all OK, then they deploy and...– Jimi
Nov 27 '18 at 20:50