process.Start()不适用于Microsoft Edge或Internet Explorer

时间:2018-08-25 00:28:26

标签: vb.net

我最近更新了我的应用程序,以将oauth用于大摇大摆的界面,这需要打开一个指向特定URL的网页并让用户授权访问。然后,我侦听发送到本地主机的响应并处理访问令牌等。为此,我只需要调用process.Start(URL)

这是我的代码:

Private Sub GetAuthorizationfromWeb()
    Try
        ' Build the authorization call
        Dim URL As String = ESIAuthorizeURL & "?response_type=code" & "&redirect_uri=http://"
        URL &= LocalHost & ":" & LocalPort & "&client_id=" & ClientID & "&scope=" & ScopesString

        Process.Start(URL)

        Dim mySocket As Socket = Nothing
        Dim myStream As NetworkStream = Nothing
        Dim myReader As StreamReader = Nothing
        Dim myWriter As StreamWriter = Nothing

        myListner.Start()

        mySocket = myListner.AcceptSocket() ' Wait for response
        Debug.Print("After socket listen")
        myStream = New NetworkStream(mySocket)
        myReader = New StreamReader(myStream)
        myWriter = New StreamWriter(myStream)
        myWriter.AutoFlush = True

        Do
            AuthStreamText &= myReader.ReadLine & "|"

            If AuthStreamText.Contains("code") Then
                Exit Do
            End If
        Loop Until myReader.EndOfStream

        myWriter.Write("Login Successful!" & vbCrLf & vbCrLf & "You can close this window.")

        myWriter.Close()
        myReader.Close()
        myStream.Close()
        mySocket.Close()
        myListner.Stop()

        Application.DoEvents()
    Catch ex As Exception
        Application.DoEvents()
    End Try

End Sub

将它们设置为默认浏览器时,所有这些功能都可以在Firefox和Chrome(在某种程度上)上正常工作。但是,当我尝试将Edge或Internet Explorer设置为默认浏览器启动URL时,它只会打开一个空白网页或主页。没有尝试导航到设置为参数的URL。

我试图找到另一种方法来执行此操作,但基本上是过程。开始似乎是唯一的选择。出于安全原因,我不会在代码中嵌入Web浏览器。

有什么想法吗?

0 个答案:

没有答案