response.transmitfile fails when deployed (ASP.NET 2)

  • Thread starter Thread starter EmeraldShield
  • Start date Start date
E

EmeraldShield

I am confused about this...

I have an app that has worked for a long time in 1.1. I upgraded it to 2.0.
Everything works on my local machine, including transmit file.

When I deploy the site to a Server 2003 (SP1) machine the transmit file
files for some reason. I don't get an exception, just the client cannot
download the file.

I saw the hotfix on the MSDN site, but that is from late 2005. I am
assuming that has been included in an update somewhere and I don't need to
apply it as a standlone patch.

Why would response.transmitfile fail on a deployed server?

Thanks
 
Hi,

Based on my understanding, TransmitFile is new in .NET 2.0 and included in
a hotfix for .NET 1.1. When you mean "have an app that has worked for a
long time in 1.1", do you mean you're already using TransmitFile in .NET
1.1?

Is the file you're sending to client using TransmitFile bigger than 2GB?

Would you please send me a reproducible project so that I can test it on my
system? Thank you for your effort and understanding.

By the way, is WriteFile working on your side?

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

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
This is an existing 1.1 app that was upgraded to 2.0. Transmit file has
been working very well for us under 1.1 for about 6 months. This is the
first time we have tried to deploy it under 2.0.

The files are very small (usually around 150KB).

This is the code in response to a button click:

if(File.Exists( logpath + filename ) == false )
{
LabelLogOutput.Text = "No log present for selected date.";
btnDownload.Visible = false;
return;
}
Response.Clear();
Response.ContentType = "application/text";
Response.AddHeader("Content-Disposition", "attachment; filename=" +
filename );
Response.TransmitFile(logpath + filename );
Response.Flush();
Response.Close();
Response.End();
return;

It is a very simple function that has worked in the past. I am not sure why
it is failing. Is there some server security settings that would prevent
transmit file from working? I guess I am just confused why changing the
project from 1.1 to 2.0 would break it on the same server. Usually I would
get a dialog to Open or Save the file.

The error I am getting is this: "Internet Explorer cannot download
thefile.aspx from secure.emeraldshield.com. Internet Explorer was not able
to open this Internet site. The requested site is either unavailable or
cannot be found. Please try again later.".

The files do exist, if they didn't the label on the form would show that
(and I tested that by trying to get it to send a file that does not exist
and I get the label update correctly).

WriteFile is giving me the same error.

The files are being served from a virtual directory in IIS. This directory
has the same permissions as the website. Site authentication is set to None
(I also tried Windows). Users are already authenticated by our code at this
point so I don't need any other authentication.

When I run it on my local machine (VS 2005 / XP Pro SP2) not using IIS
(using the development server) it works. I cannot click Open, only Save on
the dialog that comes up. If I click open I get an error that the file does
not exist, but it will save it.
 
Hi Bryan,

No, this is an existing app on Windows Server 2003. It was running under
1.1 framework and we upgraded it to 2.0. Same server, just changed the
runtime config in IIS and now transmit file stopped working.

Everything else in the site works. Data access, all the forms, just not
transmitfile.

Jason
 
EmeraldShield said:
This is an existing 1.1 app that was upgraded to 2.0. Transmit file has
been working very well for us under 1.1 for about 6 months. This is the
first time we have tried to deploy it under 2.0.

This same code works in a small test app that I built on the same server.
So it has something to do with the config of the upgraded website, I just
don't know where to even start looking. The test app is on the same server,
in the same appPool in IIS, etc. Pulling files from the same directory,
using the same mapping, and it works.

That leads me to think something within the web.config? But what in there
would effect the transmitfile function?
 
I have found the exact thing causing the problem, but not the "why" behind
it.

<%@ OutputCache NoStore="true" Location="None" %>

If we turn off page caching on a page that has transmit file, it stops
working. You get very odd behavior. Sometimes you get the dialog asking if
you want to open the page, and when you click it a "page cannot be found"
error is shown.

I have no idea WHY this happens, but this is it. Take the OutputCache out
and it all starts working.
 
Hi,

Thanks for the update.

I've been researching on this issue but didn't found known issues similar
to this. Regarding your updated information about the OutputCache directive
in the page, I've justed tested in on my win2003 sp1 but it still cannot
reproduce the issue as you're experiencing.

Per the OutputCache setting, can you reproduce it using a simple web
application?

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.
 
Yes, I do have a small sample website that I used to test it. Turning that
off fixed the problem for me. Do you want me to post it somewhere?

Thanks.
 
Hi,

Thank you very much for the update. You could just send it to me via email
if the file is smaller than 5MB.

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.
 
I am having a similar issue. I have a simple chunk of code that uses
TransmitFile(). The code works on 2 out of 3 machines. The two machines
that it works on are Win2003, the other is Win2000.

I get "Server Application Unavailable". In the event log I get:

"TransmitFile failed. File Name: xxx, Impersonation Enabled: 0, Token
Valid: 1, HRESULT: 0x8007052e "

I've tried re-writing the code several times, but it always fails. I've
tried various combinations of:
* Response.Bufferoutput = T/F
* Response.Clear()
* Response.ContentType

Currently the code is in an HttpHandler, but it did not work when it
was in the CodeBehind of a command button either.

* The file I am trying to transmit is text.
* The file I am trying to transmit is small (~2K).
* The file I am trying to transmit is accessed via UNC on another
machine.
* My Web.config is set up to use impersonation.
* Another page is able to write the file I am trying to transmit.
* The ASP.NET project is in .net 2.0/VS2005
* The ASP.NET project was upgraded from .net 1.1/2003
* I am using Web Application Projects
* When in .net 1.1, I installed the hot-fix to enable TransmitFile();
 
Hi All,

I have problem with Response.TransmitFile.
1. I try to get the file from the UNC path.
2. The site is running with Windows authentication.
3. The UNC share looks like "\\machinename\share\file.txt" and this share
has the DOMAIN USERS added with full permission.
4. I tried with impersonte true and false but fails.
5. The error I get is "Access to the path '\\machinename\share\file.txt' is
denied"
6. The code works pefectly when it is a local path.
7. Both WriteFile and TransmitFile fails.
9. The Web App is on Windows 2000, SP4 (Framework 1.1) and UNC Share is on
Windows 2003 SP1
10. :(

What kind of security setting am I missing here?

Thanks in advance
Sajid
 
Back
Top