'Request.BinaryRead'에 해당되는 글 1건

  1. 2012.12.11 [ASP & ASP.NET] POST 데이터를 바이너리 방식으로 받기
2012. 12. 11. 17:40



ASP 방식

Function BytesToStr(bytes)
    Dim Stream
    Set Stream = Server.CreateObject("Adodb.Stream")
        Stream.Type = 1 'adTypeBinary
        Stream.Open
        Stream.Write bytes
        Stream.Position = 0
        Stream.Type = 2 'adTypeText
        Stream.Charset = "iso-8859-1"
        BytesToStr = Stream.ReadText
        Stream.Close
    Set Stream = Nothing
End Function
If Request.TotalBytes > 0 Then
    Dim lngBytesCount
        lngBytesCount = Request.TotalBytes
    Response.Write BytesToStr(Request.BinaryRead(lngBytesCount))
End If


ASP.NET 방식

string jsonMessage = string.Empty;
System.IO.Stream inputStream = HttpContext.Current.Request.InputStream;
byte[] inputBuffer = new byte[inputStream.Length];
inputStream.Read(inputBuffer, 0, inputBuffer.Length);

try
{
	jsonMessage = System.Text.Encoding.UTF8.GetString(inputBuffer);
}
catch (Exception ex)
{
	throw ex;
}

return jsonMessage;

Posted by CoolDragon