Bonjour,

J'ai un petit problème.

J'ai fais une requête POST JSON en Visual Basic,

et j'aimerai y implémenter des proxys,

tous fonctionnes mais, quand je mets un mauvais proxy, microsoft visual stuido ferme le logiciel et me mets ceci:
"
Une exception non gérée du type 'System.UriFormatException' s'est produite dans System.dll



Informations supplémentaires : URI non valide : Impossible d'analyser le nom d'hôte.
"
donc à la place de faire ça, y'aurai t'il un moyen de me dire dans un msgbox genre " Proxy non-fonctionnel" ?

et pour ceux qui ont besoins du code:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
 
    Public Function Login(ByVal Username As String, ByVal Password As String, ByVal proxy As String)
        Try
            Dim proxyer As New WebProxy(proxy)
            Dim WR As WebRequest = WebRequest.Create("https://authserver.mojang.com/authenticate")
            WR.Method = "POST"
            WR.Proxy = proxyer
            WR.Timeout = 8000
            Dim PostData As String = "{""agent"": {""name"": ""Minecraft"",""version"": 1},""username"": """ & Username & """,""password"": """ & Password & """,""requestUser"":true}"
            WR.ContentType = "application/json"
            Dim ByteArray As Byte() = Encoding.UTF8.GetBytes(PostData)
            WR.ContentLength = ByteArray.Length
            Dim DataStream As Stream = WR.GetRequestStream
            DataStream.Write(ByteArray, 0, ByteArray.Length)
            DataStream.Close()
            Dim JsonResponse As WebResponse = WR.GetResponse
            DataStream = JsonResponse.GetResponseStream
            Dim SR As New StreamReader(DataStream)
            Dim Response As String = SR.ReadToEnd
            Dim DecodedJson As New JObject
            DecodedJson = JsonConvert.DeserializeObject(Response)
            Player = DecodedJson.Item("selectedProfile").Item("name").ToString
            Uuid = DecodedJson.Item("selectedProfile").Item("id").ToString
            AccessToken = DecodedJson.Item("accessToken").ToString
            ClientToken = DecodedJson.Item("clientToken").ToString
        Catch ex As WebException
            Dim SR As New StreamReader(ex.Response.GetResponseStream)
            Dim DecodedJson As New JObject
            DecodedJson = JsonConvert.DeserializeObject(SR.ReadToEnd)
            LoggedIn = False
            Return False
            Exit Function
        End Try
        LoggedIn = True
        Return True
    End Function