472,373 Members | 1,586 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,373 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 2759
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. ...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.
0
DizelArs
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...

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.