
BinaryWrite | 377
HttpResponse
Class
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
Example
The following example retrieves a virtual path including the SessionID and
displays the path by using the Text property of the Message label control:
Sub Page_Load( )
Dim NewPath As String
NewPath = Response.ApplyAppPathModifier(Request.Path)
Message.Text = "Modified virtual path = " & NewPath
End Sub
The web.config file to set the Session state handler to use cookieless Sessions is
shown below:
<configuration>
<system.web>
<sessionState mode="InProc" cookieless="true"/>
</system.web>
</configuration>
Notes
This method is very useful when making use of the cookieless Session state func-
tionality introduced by ASP.NET. If the cookieless attribute of the
sessionState
config section in web.config is not set to True, this method will simply return the
virtual path passed in without modification.
BinaryWrite
Response.BinaryWrite(ByVal buffer( ) As Byte)
Allows writing of binary content to the output stream. No modification of the
output is performed before sending the binary content to the client.
Parameter
buffer( )
A Byte array containing the binary data to be written to the output stream.
Example
Here is an example of BinaryWrite:
Sub Page_Load( )
Dim ImageStream As New FileStream(MapPath("aspnetian.jpg"), _
FileMode.Open, FileAccess.Read)
Dim ImageBytes(ImageStream.Length) ...