473,387 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Response.TransmitFile - Windows Mobile 6.0

Hi,

I have use the following code to transmit a file back to the browser that
worked fine on a HTC_TTyN device running windows mobile 5.0. The code
executes in the onclick event of a mobilelist control. Now on a similar
device running window mobile 6.0 the file is not displayed - the link causes
a post back succesfully and the code appears to execute - on the browser a
bar is displayed breifely at the bottom of the window (although ist show 0KB
to the right of the bar.) - seaming to indciate that a file is being
transferred but the file save option (or the file) does not appear.

Does any one have any ideas why this is not working ? I suspect it may be
something that is specific to the HCT_TTyn devcie as we have identifed a
separate issue where the browser capabilities where not being detected
correctly - this was due to the fact that the useragent string was being
prefixed with 'HCT_TTyn ' - to work around this we have defined a new
htctty.browser file and registered it with asp.net which seams to have solved
all the problems we were having - apart from this file transfer issue.

protected bool SendFile(string filePath)
{
string fileName = System.IO.Path.GetFileName(filePath);
if ((fileName != "") && (System.IO.File.Exists(filePath)))
{
try
{
Response.Clear();
Response.ClearHeaders();
Response.ClearContent();
Response.ContentType = "application/octet-stream";
Response.AddHeader("content-disposition", @"attachment;
filename=""" + fileName + @"""");
Response.AddHeader("content-length", new
System.IO.FileInfo(filePath).Length.ToString());
Response.TransmitFile(filePath);
Response.Flush();
Response.End();
Response.Close();
return true;
}
catch
{
return false;
}
}
else
return false;
}

Nov 26 '07 #1
1 2833
Hi Woodgnome,

As for the file downloading issue you mentioned, I think your analysis is
reasonable. for mobile or smart device requests, the http useragent is the
default evidence of the device and ASP.NET runtime will probably respond
quite different due to it.

I think you can make some simple tests to verify the behavior. You can use
some .NET winform client application to send http request(with the
useragent set to the same value as your smart device), if the response (you
can view it through some network trace tool or directly get it through
network component such as HttpWebRequest) still give the same problem
result, the problem should be caused by the device's useragent. And for
such case, I think customize the server application's browser/device
detection setting should be the reasonable method.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

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/subscripti...t/default.aspx.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>Thread-Topic: Response.TransmitFile - Windows Mobile 6.0
thread-index: AcgwM8zdaNC3/emhQ3OlyEuh+rCpgA==
X-WBNR-Posting-Host: 82.110.100.247
From: =?Utf-8?B?V29vZGdub21l?= <wo*******@community.nospam>
Subject: Response.TransmitFile - Windows Mobile 6.0
Date: Mon, 26 Nov 2007 05:54:01 -0800
>
Hi,

I have use the following code to transmit a file back to the browser that
worked fine on a HTC_TTyN device running windows mobile 5.0. The code
executes in the onclick event of a mobilelist control. Now on a similar
device running window mobile 6.0 the file is not displayed - the link
causes
>a post back succesfully and the code appears to execute - on the browser a
bar is displayed breifely at the bottom of the window (although ist show
0KB
>to the right of the bar.) - seaming to indciate that a file is being
transferred but the file save option (or the file) does not appear.

Does any one have any ideas why this is not working ? I suspect it may be
something that is specific to the HCT_TTyn devcie as we have identifed a
separate issue where the browser capabilities where not being detected
correctly - this was due to the fact that the useragent string was being
prefixed with 'HCT_TTyn ' - to work around this we have defined a new
htctty.browser file and registered it with asp.net which seams to have
solved
>all the problems we were having - apart from this file transfer issue.

protected bool SendFile(string filePath)
{
string fileName = System.IO.Path.GetFileName(filePath);
if ((fileName != "") && (System.IO.File.Exists(filePath)))
{
try
{
Response.Clear();
Response.ClearHeaders();
Response.ClearContent();
Response.ContentType = "application/octet-stream";
Response.AddHeader("content-disposition",
@"attachment;
>filename=""" + fileName + @"""");
Response.AddHeader("content-length", new
System.IO.FileInfo(filePath).Length.ToString()) ;
Response.TransmitFile(filePath);
Response.Flush();
Response.End();
Response.Close();
return true;
}
catch
{
return false;
}
}
else
return false;
}

Nov 27 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: jeffpriz | last post by:
I'm have a situation where I need to put a download link/button on a page, where the file to be downloaded does not exist on our webservers .... So I'm using Response.WriteFile (i've also tried...
1
by: Oct | last post by:
I have implemented an ISAPI filter to authenticate user download based on SQL data. It works great for all high speed users but it fail after 20-30 mins download on modem (yes, 56k!) user. The...
0
by: Thomas Andersson | last post by:
Hi, I have a problem with Response.TransmitFile. The server reset the connection after approx. 20 minutes and sometimes after 7-8 minutes when i try to download large files (400MB +) with...
1
by: Ryan Pedersen | last post by:
I have been trying to figure out how to transmit a file back to a user using the response.transmitfile or response.writefile method and just not having much success. I have a dell server running...
0
by: Ryan Pedersen | last post by:
I have a HttpHandler configured to use Response.TransmitFile. It is working error free when the server is in HTTP mode. In HTTPS mode it apears to work but after a users selects the location to save...
3
by: Buddy Ackerman | last post by:
I'm trying to write files directly to the client so that it forces the client to open the Save As dialog box rather than display the file. On some occasions the files are very large (100MB+). On...
2
by: mgalvez | last post by:
I'm developing an interface that sends a file to the client. it works but the client also gets an "Action canceled" page (IE) how can I remove this page? or display the application home page? ...
1
by: APA | last post by:
I am transmitting files using response.transmitfile. I only have a problem using it with MP3s. Larger files (20MB+ ZIP files) are no problem. I'm using an HttpHandler in .NET 1.1 on Windows 2003...
2
by: Michael D. Ober | last post by:
When I single step through the code below, it sends back the PDF file that is retrieved in the line fm.GetAccountPDF(...). When I run without single stepping, I get the master page for this page. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.