Hi, all!
The following code worked fine always to connect to my website via HTTP, but since the connection to the site changed to HTTPS (a security certificate was installed), it stopped working.
Please, tell me how to solve this problem and how to make changes to the code so that it works with web sites using the HTTPS protocol.
Or maybe the reason is different?
Thank you in advance for any help!
fn webRequest = (
try (
local request = (dotNetClass "System.Net.WebRequest").Create ("https://www.mywebsite.com");
request.Method = "GET"
request.Timeout = 1000
request.UserAgent = "3ds Max"
local response = request.getResponse()
local responseStream = response.GetResponseStream()
local encodingClass = dotNetClass "System.Text.Encoding"
local encoding = encodingClass.GetEncoding "utf-8"
local readStream = dotNetObject "System.IO.StreamReader" responseStream encoding
local webanswer = readStream.ReadToEnd()
readStream.Close()
response.Close()
return webanswer
)
catch(print (getCurrentException()))
)
webRequest()
Result:
-- Runtime error: dotNet runtime exception: Authentication failed because the remote party has closed the transport stream.