Hi Param,
I've some further communiation with our IIS dev guys and seems the first
layer IIS extending development through pure .net managed code is still not
available for IIS6. We may still have to wait for vista/iis7 which will
support full IIS extending through managed code....
Thanks,
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| X-Tomcat-ID: 38770351
| References: <un************ **@TK2MSFTNGP15 .phx.gbl>
<el************ **@TK2MSFTNGP14 .phx.gbl>
<Ov************ *@TK2MSFTNGP09. phx.gbl>
<06************ **@TK2MSFTNGXA0 2.phx.gbl>
<O3************ **@TK2MSFTNGP14 .phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
| From:
st*****@online. microsoft.com (Steven Cheng[MSFT])
| Organization: Microsoft
| Date: Fri, 25 Nov 2005 02:38:14 GMT
| Subject: Re: streaming binary data from sql 2005
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
| Message-ID: <6V************ **@TK2MSFTNGXA0 2.phx.gbl>
| Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| Lines: 287
| Path: TK2MSFTNGXA02.p hx.gbl
| Xref: TK2MSFTNGXA02.p hx.gbl
microsoft.publi c.dotnet.framew ork.aspnet:3608 30
| NNTP-Posting-Host: tomcatimport2.p hx.gbl 10.201.218.182
|
|
| Thanks for your response Param,
|
| Regarding on developing IIS components through managed code in .net 2.0,
| seems there hasn't detailed public reference. I'll contact some other IIS
| experts to see whether they have any information on this. Also, for
| developing raw ISAPI extension or filters, here're some reference:
|
|
| #Taking the SplashDiving into ISAPI Programming
|
http://www.microsoft.com/mind/0197/isapi.asp
|
| #ISAPI Extensions: Creating a DLL to Enable HTTP-based File Uploads with
IIS
|
http://msdn.microsoft.com/msdnmag/is...d/default.aspx
|
| Steven Cheng
| Microsoft Online Support
|
| Get Secure!
www.microsoft.com/security
| (This posting is provided "AS IS", with no warranties, and confers no
| rights.)
| --------------------
| | From: <pa***@communit y.nospam>
| | References: <un************ **@TK2MSFTNGP15 .phx.gbl>
| <el************ **@TK2MSFTNGP14 .phx.gbl>
| <Ov************ *@TK2MSFTNGP09. phx.gbl>
| <06************ **@TK2MSFTNGXA0 2.phx.gbl>
| | Subject: Re: streaming binary data from sql 2005
| | Date: Thu, 24 Nov 2005 08:24:43 -0600
| | Lines: 238
| | X-Priority: 3
| | X-MSMail-Priority: Normal
| | X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
| | X-RFC2646: Format=Flowed; Original
| | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
| | Message-ID: <O3************ **@TK2MSFTNGP14 .phx.gbl>
| | Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| | NNTP-Posting-Host: corp2.lazardgro up.com 70.182.148.88
| | Path: TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP14.phx. gbl
| | Xref: TK2MSFTNGXA02.p hx.gbl
| microsoft.publi c.dotnet.framew ork.aspnet:3607 30
| | X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
| |
| | Steve, do you have some links to some samples on how to develop an
isapi
| | filter in .net 2.0? I have never attempted that before and dont know
| where
| | to begin. We are working on a large app where pdf files have to be
| securely
| | stored in a sql database & streamed down to users in their browser. We
| are
| | expecting upto 10,000+ simultaneous users at any given time.
| |
| | TIA!
| |
| | "Steven Cheng[MSFT]" <st*****@online .microsoft.com> wrote in message
| | news:06******** ******@TK2MSFTN GXA02.phx.gbl.. .
| | > Hi Param,
| | >
| | > I think the Buffering Bruce mentioned means the OutputBuffer setting
for
| | > asp.net web page. We can set it in the @Page directive like:
| | >
| | > <%@Page ..... Buffer="true". .... %>
| | >
| | > or in code through:
| | >
| | > Page_load(...)
| | > {
| | > Response.Buffer Output = true;
| | > }
| | >
| | > The default should be ture. Setting Buffer can help us buffer the
| response
| | > data at serversdie so as to flush them once all the data is complete.
| | > However, this will cause the server memory be comsumed seriously when
| lots
| | > of request executing for large data downloading.... .
| | >
| | > Also, I think it'll be better to implement file download in raw IIS
| isapi
| | > filter or extension and seems .NET 2.0 support developing IIS isapi
| | > components through managed code..
| | >
| | > Thanks,
| | >
| | > Steven Cheng
| | > Microsoft Online Support
| | >
| | > Get Secure!
www.microsoft.com/security
| | > (This posting is provided "AS IS", with no warranties, and confers no
| | > rights.)
| | >
| | >
| | >
| | > --------------------
| | > | From: <pa***@communit y.nospam>
| | > | References: <un************ **@TK2MSFTNGP15 .phx.gbl>
| | > <el************ **@TK2MSFTNGP14 .phx.gbl>
| | > | Subject: Re: streaming binary data from sql 2005
| | > | Date: Wed, 23 Nov 2005 20:19:04 -0600
| | > | Lines: 156
| | > | X-Priority: 3
| | > | X-MSMail-Priority: Normal
| | > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
| | > | X-RFC2646: Format=Flowed; Response
| | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
| | > | Message-ID: <Ov************ *@TK2MSFTNGP09. phx.gbl>
| | > | Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| | > | NNTP-Posting-Host: corp2.lazardgro up.com 70.182.148.88
| | > | Path:
TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP09.phx. gbl
| | > | Xref: TK2MSFTNGXA02.p hx.gbl
| | > microsoft.publi c.dotnet.framew ork.aspnet:3606 09
| | > | X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
| | > |
| | > | Hi, could you please shed some light on "buffering the download" ?
| Here
| | > is
| | > | my code right now. I call the dbchunks2stream method which
essentially
| | > | chunks the data to response.output stream
| | > |
| | > | Public Sub WriteChunks2DB( tablename as string, columnname as
string,
| | > | pkcolumnname as string, pkcolumnval as string, s as stream)
| | > | Dim BUFFER_LENGTH As Integer = 131072 ' chunk size
| | > |
| | > | ' Make sure that Photo is non-NULL and return TEXTPTR to it.
| | > | Dim sqlstr as string = "SET NOCOUNT ON;UPDATE " + tablename + "
| SET
| | > "
| | > +
| | > | columnname + " = 0x0 WHERE " + pkcolumnname + "= '" +
| | > | replacequotes(p kcolumnval) + "';SELECT @Pointer=TEXTPT R(" +
| columnname +
| | > ")
| | > | FROM " + tablename + " WHERE " + pkcolumnname + " = '" +
| | > | replacequotes(p kcolumnval) + "'"
| | > | Dim cmdGetPointer As New SqlCommand(sqls tr, objConnect)
| | > | Dim PointerOutParam As SqlParameter =
| | > | cmdGetPointer.P arameters.Add(" @Pointer", SqlDbType.VarBi nary, 100)
| | > | PointerOutParam .Direction = ParameterDirect ion.Output
| | > | if objConnect.stat e = ConnectionState .Closed Then objConnect.Open
| | > |
| | > | cmdGetPointer.E xecuteNonQuery( )
| | > |
| | > | ' Set up UPDATETEXT command, parameters, and open BinaryReader.
| | > | sqlstr = "UPDATETEXT " + tablename + "." + columnname + "
@Pointer
| | > | @Offset @Delete WITH LOG @Bytes"
| | > | Dim cmdUploadBinary As New SqlCommand(sqls tr, objConnect)
| | > | Dim PointerParam As SqlParameter =
| | > | cmdUploadBinary .Parameters.Add ("@Pointer", SqlDbType.Binar y, 16)
| | > | Dim OffsetParam As SqlParameter =
| | > | cmdUploadBinary .Parameters.Add ("@Offset", SqlDbType.Int)
| | > | Dim DeleteParam As SqlParameter =
| | > | cmdUploadBinary .Parameters.Add ("@Delete", SqlDbType.Int)
| | > | DeleteParam.Val ue = 1 ' delete 0x0 character
| | > | Dim BytesParam As SqlParameter =
| | > | cmdUploadBinary .Parameters.Add ("@Bytes", SqlDbType.Binar y,
| | > BUFFER_LENGTH)
| | > | Dim br As New BinaryReader(s)
| | > | Dim Offset As Integer = 0
| | > | OffsetParam.Val ue = Offset
| | > |
| | > | ' Read buffer full of data and execute the UPDATETEXT statement.
| | > | Dim Buffer() As Byte = br.ReadBytes(BU FFER_LENGTH)
| | > | Do While Buffer.Length > 0
| | > | PointerParam.Va lue = PointerOutParam .Value
| | > | BytesParam.Valu e = Buffer
| | > | cmdUploadBinary .ExecuteNonQuer y()
| | > | DeleteParam.Val ue = 0 ' don't delete any other data
| | > | Offset += Buffer.Length
| | > | OffsetParam.Val ue = Offset
| | > | Buffer = br.ReadBytes(BU FFER_LENGTH)
| | > | Loop
| | > |
| | > | br.Close()
| | > | s.Close()
| | > | objConnect.Clos e()
| | > |
| | > | End Sub
| | > |
| | > | Public Sub DBChunks2Stream (tablename as string, columnname as
string,
| | > | pkcolumnname as string, pkcolumnval as string, byref s as stream)
| | > | Dim ImageCol As Integer = 0 ' position of image column in
| DataReader
| | > | Dim BUFFER_LENGTH As Integer = 131072 ' chunk size
| | > |
| | > | ' Make sure that Photo is non-NULL and return TEXTPTR to it.
| | > | Dim sqlstr as string = "SELECT @Pointer=TEXTPT R(" + columnname
+
| "),
| | > | @Length=DataLen gth(" + columnname + ") FROM " + tablename + " WHERE
"
| +
| | > | pkcolumnname + " = '" + pkcolumnval + "'"
| | > | Dim cmdGetPointer As New SqlCommand(sqls tr, objConnect)
| | > | Dim PointerOutParam As SqlParameter =
| | > | cmdGetPointer.P arameters.Add(" @Pointer", SqlDbType.VarBi nary, 100)
| | > | PointerOutParam .Direction = ParameterDirect ion.Output
| | > | Dim LengthOutParam As SqlParameter =
| | > | cmdGetPointer.P arameters.Add(" @Length", SqlDbType.Int)
| | > | LengthOutParam. Direction = ParameterDirect ion.Output
| | > | if objConnect.stat e = ConnectionState .Closed Then
objConnect.Open
| | > | cmdGetPointer.E xecuteNonQuery( )
| | > | If PointerOutParam .Value Is DBNull.Value Then
| | > | objConnect.Clos e()
| | > | ' Add code to deal with NULL BLOB.
| | > | Exit Sub
| | > | End If
| | > |
| | > | ' Set up READTEXT command, parameters, and open BinaryReader.
| | > | sqlstr = "READTEXT " + tablename + "." + columnname + " @Pointer
| | > @Offset
| | > | @Size HOLDLOCK"
| | > | Dim cmdReadBinary As New SqlCommand(sqls tr, objConnect)
| | > | Dim PointerParam As SqlParameter =
| | > | cmdReadBinary.P arameters.Add(" @Pointer", SqlDbType.Binar y, 16)
| | > | Dim OffsetParam As SqlParameter =
| | > | cmdReadBinary.P arameters.Add(" @Offset", SqlDbType.Int)
| | > | Dim SizeParam As SqlParameter =
| | > cmdReadBinary.P arameters.Add(" @Size",
| | > | SqlDbType.Int)
| | > | Dim dr As SqlDataReader
| | > | Dim Offset As Integer = 0
| | > | OffsetParam.Val ue = Offset
| | > | Dim Buffer(BUFFER_L ENGTH - 1) As Byte
| | > |
| | > | ' Read buffer full of data and write to the file stream.
| | > | Do
| | > | PointerParam.Va lue = PointerOutParam .Value
| | > | ' Calculate the buffer size - may be less than BUFFER_LENGTH
| for
| | > the
| | > | last block.
| | > | If Offset + BUFFER_LENGTH >= Cint(LengthOutP aram.Value) Then
| | > | SizeParam.Value = Ctype((Cint(Len gthOutParam.Val ue) -
| Offset),
| | > | Object)
| | > | Else
| | > | SizeParam.Value = Ctype(BUFFER_LE NGTH, Object)
| | > | End If
| | > | dr = cmdReadBinary.E xecuteReader(Co mmandBehavior.S ingleResult)
| | > | dr.Read()
| | > | dr.GetBytes(Ima geCol, 0, Buffer, 0, Cint(SizeParam. Value))
| | > | dr.Close()
| | > | s.Write(Buffer, 0, Cint(SizeParam. Value))
| | > | Offset += Cint(SizeParam. Value)
| | > | OffsetParam.Val ue = Ctype(Offset, Object)
| | > | Loop Until Offset >= Cint(LengthOutP aram.Value)
| | > |
| | > | s.Close()
| | > | objConnect.Clos e()
| | > |
| | > | End Sub
| | > |
| | > |
| | > |
| | > | TIA!
| | > |
| | > |
| | > | "Bruce Barker" <br************ ******@safeco.c om> wrote in message
| | > | news:el******** ******@TK2MSFTN GP14.phx.gbl...
| | > | > the technique is the same. you will gain a performance boost if
you
| | > switch
| | > | > to a varbinary(max) column over image. there are improvements in
| | > | > transferring the data.
| | > | >
| | > | > note: using asp.net for downloads is problematic. asp.net has a
| | > limited
| | > | > number of request threads and a limited number of connection from
| the
| | > | > asp.net worker process to .net isapi filter. this means you can
not
| | > | > support a lot of simultaneous downloads. even though its heavy on
| | > | > resources, you might fiond buffering the download is best. this
| fress
| | > up
| | > | > the asp.net worker thread quicker.
| | > | >
| | > | >
| | > | > -- bruce (sqlwork.com)
| | > | >
| | > | >
| | > | > <pa***@communit y.nospam> wrote in message
| | > | > news:un******** ******@TK2MSFTN GP15.phx.gbl...
| | > | >> Hi all, is there a better way to stream binary data stored in a
| table
| | > in
| | > | >> sql 2005 to a browser in .net 2.0? Or is the code same as in
net
| | > 1.1?
| | > We
| | > | >> noticed that in certain heavy load scenarios, every now and then
| the
| | > | >> client would timeout and have to re-initiate the request...
| | > | >>
| | > | >> TIA!
| | > | >>
| | > | >
| | > | >
| | > |
| | > |
| | > |
| | >
| |
| |
| |
|
|