Error using TransmitFile() with asp.net 2.0 on windows xp

M

MatsL

Hi,
I'm having a problem sending a file using TransmitFile().
The code works perfectly using WriteFile() so I'm a little confused.
Does TransmitFile() have any other prerequisites than WriteFile()?

Here's a short snippet of the code I use that doesn't work:
protected void Page_Load(object sender, EventArgs e)
{
// The context items are set in a httpmodule
Response.ContentType = (string)Context.Items["format"];
Response.TransmitFile((string)Context.Items["filename"]);
}

If I use WriteFile there instead the code works!

The error that shows up in the event log is as follows

TransmitFile failed. File Name: C:\\Inetpub\\wwwroot\\TestfileSecure.jpg






, Impersonation Enabled:
0, Token Valid: 1, HRESULT: 0x80070003


Since it works with WriteFile() I think my permissions for the file are
correct (I've set all permissions for 'Everyone' and made the IIS run
under an administrator account also to rule out any permission errors).

Thanks in advance
/Mats Lycken
 
W

Walter Wang [MSFT]

Hi Mats,

Both HttpResponse.WriteFile and HttpResponse.TransmitFile (new in 2.0)
write the contents of a file to the output stream. However, WriteFile will
load the whole file into the memory while TransmitFile won't.

There's one known issue of TransmitFile on Windows 2003 SP1:

#FIX: You cannot use the Response.TransmitFile method to transfer a file
from a Windows Server 2003 SP 1-based computer to a client computer
http://support.microsoft.com/?kbid=902780

But since you're using Windows XP, I think this might not be the cause.

I've done some test on Windows XP both using the File System mode and IIS
mode, both work correctly. I just did a simple TransmitFile which outputs a
GIF file.

I suggest you create a very simple WebSite using File System mode and just
call Response.TransmitFile(filename) and see if it works or not.

It would be great if you can create a repro project and attach it here or
send it to me.


Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
M

MatsL

Hi, I created a simple website and it worked. The thing is that my other
webapplication is a little more complex. I use a httpmodule with
Context.RewritePath to create friendly url's, maybe that affects my result.

I thought that the problems with TransmitFile had gone away with 2.0.
I'm afraid I can't use TransmitFile then since we run server 2003 on our
production servers.
 
W

Walter Wang [MSFT]

Hi Mats,

It would be very helpful if you could create a repro project which
demostrates the issue with the HttpModule and Context.RewritePath.

For the Windows 2003 SP1 issue mentioned in the KB 902780, we have a hotfix
available upon your request.

However, although TransmitFile makes large file downloads more stable than
ever and defeats the problem of recycling, it is far from being a full
solution to the problem of tracking and resuming large file downloads. For
example, if a download fails, for whatever reason, TransmitFile can start
it again only from the beginning. The article located at the Web site
http://www.devx.com/dotnet/Article/22533 discusses a better approach to the
problem.

Hope this helps. Please feel free to post here if anything is unclear.



Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top