Basically, Here is the scenario.I created mobile optimised ASP.NET(3.5 framework) apllication and I added a link to download xml file on to Motorola GUN which runs on comapct framework 5.0 operation system.
File download logic works fine on desktop/laptop but on windows CE device Instead of downloading the file.It is opening xml file in IE browser.
I need experties help here :)
The device is going to handle files that it is designed for.
You could try sending your file as an octet stream.
Here is something similar I did a while back, but I'm not certain if it works on Mobile devices:
if (!String.IsNullOrEmpty(nameOnly)) {
string filename = Server.MapPath(nameOnly);
if (!String.IsNullOrEmpty(filename)) {
try {
Response.Buffer = false;
Response.Clear(); // clear the buffer
Response.Cache.SetCacheability(HttpCacheability.NoCache);
if (-1 < filename.IndexOf(".avi")) {
Response.ContentType = "video/x-msvideo";
} else if (-1 < filename.IndexOf(".pdf")) {
Response.ContentType = "Application/pdf";
} else if (-1 < filename.IndexOf(".rar")) {
Response.ContentType = "Application/x-rar-compressed";
} else {
Response.ContentType = "Application/octet-stream";
}
FileInfo file = new FileInfo(filename);
Response.AddHeader("Content-Disposition", "attachment; filename=" + nameOnly);
Response.AddHeader("Content-Length", file.Length.ToString());
Response.WriteFile(file.FullName);
} catch (Exception err) {
outputLine = err.Message;
} finally {
Response.Flush();
}
} else {
outputLine = string.Format("Server was unable to locate file \"{0}\".", nameOnly);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.