How can i open a url in web browser (such as IE) and pass credentials

前端 未结 5 1076
傲寒
傲寒 2020-12-09 10:15

I want to open a page that required Basic authentication. I want to pass the Basic authentication header to the browser along with the URL.

How can i do that?

5条回答
  •  情书的邮戳
    2020-12-09 10:58

    First check this code:

    Dim result As String
    
    Using wClnt As New Net.WebClient
    
        wClnt.Credentials = New System.Net.NetworkCredential("username", "password")
    
        Using strR As New IO.StreamReader(wClnt.OpenRead("http://ADDRESS_To_READ"))
    
            result = strR.ReadToEnd
    
        End Using
    
    End Using
    

    If it was not what your where looking for, Check this post, it may help:

    How do I log into a site with WebClient?

    Update:

    This way you are not opening any browser. Just requesting the address you want and passing Credential.

提交回复
热议问题