當前位置: 首頁>>代碼示例>>VB.NET>>正文


VB.NET HttpListenerResponse.ProtocolVersion屬性代碼示例

本文整理匯總了VB.NET中System.Net.HttpListenerResponse.ProtocolVersion屬性的典型用法代碼示例。如果您正苦於以下問題:VB.NET HttpListenerResponse.ProtocolVersion屬性的具體用法?VB.NET HttpListenerResponse.ProtocolVersion怎麽用?VB.NET HttpListenerResponse.ProtocolVersion使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。


在下文中一共展示了HttpListenerResponse.ProtocolVersion屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。

示例1: SendBadCertificateResponse

Private Shared message403 As String
Private Shared preMade403Response As HttpListenerResponse
Private Shared Sub SendBadCertificateResponse(ByVal response As HttpListenerResponse)
    
    If preMade403Response Is Nothing Then
        ' Set up an authentication error response template.
        response.StatusCode = Cint(HttpStatusCode.Forbidden)
        response.StatusDescription = "403 Forbidden"
        response.ProtocolVersion = New Version("1.1")
        response.SendChunked = False
    Else
        response.CopyFrom(preMade403Response) 
    End If
    
    ' The response body cannot be saved in the template.
    Dim message As New StringBuilder()
    message.Append("<HTML><BODY>")
    message.Append("<p> Error message 403: Access is denied due to a missing or invalid client certificate.</p>")
    message.Append("</BODY></HTML>")
    message403 = message.ToString()

    ' Turn the error message into a byte array using the 
    ' encoding from the response when present.
    Dim encoding As System.Text.Encoding = response.ContentEncoding
    If encoding Is Nothing Then
        encoding = System.Text.Encoding.UTF8
        response.ContentEncoding = encoding
    End If

    Dim buffer() As Byte = encoding.GetBytes(message403)
    response.ContentLength64 = buffer.Length
    ' Write the error message.
    Dim stream As System.IO.Stream = response.OutputStream
    stream.Write(buffer, 0, buffer.Length)
    ' Send the response.
    response.Close()
End Sub
開發者ID:VB.NET開發者,項目名稱:System.Net,代碼行數:37,代碼來源:HttpListenerResponse.ProtocolVersion


注:本文中的System.Net.HttpListenerResponse.ProtocolVersion屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。