[Mono-list] HttpResponse.TransmitFile method

Kornél Pál kornelpal at hotmail.com
Fri Aug 19 03:08:22 EDT 2005


Response.TransmitFile
(http://msdn2.microsoft.com/library/12s31dhy(en-us,vs.80).aspx) is supposed
to to high performance direct file to socket transmission. On Win32 using
TransmitFile API
(http://msdn.microsoft.com/library/en-us/winsock/winsock/transmitfile_2.asp).
MS ASP.NET implements this through HSE_REQ_TRANSMIT_FILE IIS support
function
(http://msdn.microsoft.com/library/en-us/iissdk/html/d685131e-51bf-446c-b4bb-4770973460df.asp).

Response.Redirect sends 301 response to the browser and Server.Transfer
executes another request URL that will be executed by the appropriate
handler specified in configuration.

As you can see Response.TransmitFile is no way related to these two methods.
Response.TransmitFile send a file in entiry body, Response.Redirect uses
client side redirect and Server.Transfer uses server side redirect limited
to ASP.NET.

If you want to protect *.zip, *.wmv and *.jpg using ASP.NET you should
configure Apache to handle these files using mod_mono.

Then you could use an authentication module or forms authentication and
StaticFileHandler (assigned to all files by default).

MS.NET StaticFileHandler supports Range and If-Range and caching as well.
These are not implemented in Mono.

StaticFileHandler uses Response.WriteFile but should be considered to use
Response.TransmitFile instead.

Response.TransmitFile is not implemented by Mono and should be implemented
in mod_mono in fact.

If you need the missing functionality you should implement it.

If you don't want to handle the request using ASP.NET then I think you can
only edit Apache configuaration files using an ASP.NET page to allow or
disallow download from a specific IP for example and then redirect user to a
different location protected using configuration file. I think this solution
should not be used.

Kornél

----- Original Message -----
From: "Marc DM" <m at phronein.com>
Cc: <mono-list at lists.ximian.com>
Sent: Friday, August 19, 2005 7:32 AM
Subject: Re: [Mono-list] HttpResponse.TransmitFile method


> Hey all,
>
> this issue has come back to bite me in the ass.
>
> Response.WriteFile works in Mono/Debian just like it does on Win2k/.NET
>
> It spools the file into RAM before feeding it out to the client.
>
> Response.TransmitFile is supposed to perform the same action as if you
> use Response.Redirect or Server.Transfer without restarting the page
> processing.
>
> Anyone have any ideas on how to protect *.zip, *.wmv and *.jpg files
> behind an apache server with mono/mod_mono?
>
> Thanks.
>
> MDM
>
> On Tue, 2005-06-14 at 15:54 -0700, Joe Audette wrote:
>> Why not use Response.WriteFile?
>>
>> I use it in mono and it works great.
>>
>> Joe
>>
>> --- Marc DM <m at phronein.com> wrote:
>>
>> >
>> > Would it be possible for a future release of mono to
>> > include the
>> > unpopular method of the HttpResponse object named
>> > TransmitFile
>> >
>> > Microsoft implemented this method as a solution to
>> > HttpResponse.BinaryWrite spooling the entire file
>> > into RAM before
>> > sending it to the web-user. (see KB article link
>> > below)
>> >
>> > I did a google search for "mono
>> > Request.TransmitFile" (without the
>> > quotes) and got 1 english result.
>> > The method isn't documented in MSDN but I found this
>> > on Microsoft's
>> > site :
>> > (from
>> >
>> http://support.microsoft.com/default.aspx?scid=kb;en-us;823409)
>> >
>> >
>> > > You can use the function instead of the
>> > BinaryWrite function or
>> > > instead of other functions to send files to the
>> > client. Also, this
>> > > function can be used regardless of the size of the
>> > file that you want
>> > > to transmit.
>> >
>> > I also found this blog entry explaining its
>> > functionality (a bit)
>> >
>> http://www.aaronweiker.com/PermaLink,guid,2e9e9d7f-4130-41f7-8104-171f3ece37d4.aspx
>> >
>> > I need this method to compile some code I'm moving
>> > from .NET to mono.
>> > I suspect that I'll have to find another way around
>> > this one.
>> >
>> > Has anybody got any ideas?
>> >
>> > Thanks in advance,
>> >
>> > Marc DM
>> > > _______________________________________________
>> > Mono-list maillist  -  Mono-list at lists.ximian.com
>> > http://lists.ximian.com/mailman/listinfo/mono-list
>> >
>>
>>
>> joe_audette [at] yahoo dotcom
>> http://www.joeaudette.com
>> http://www.mojoportal.com
>> _______________________________________________
>> Mono-list maillist  -  Mono-list at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-list
>>
>
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>



More information about the Mono-list mailing list