I've trouble with my web apps, im using MVC3, here is my scratch code :
public FileResult ViewPRAttachAjax(Int64 Id)
{
//String StrCode = Request["q"].ToString();
//Int64 Id = Int64.Parse(StrCode);
//nulis ke file
RequsitionAttachmentRepository reqAttach = new RequsitionAttachmentRepository();
RequsitionAttachmentViewModel att = reqAttach.GetAttachment(Id).SingleOrDefault();
var physicalPath = Path.Combine(Server.MapPath("~/Content/Files/"), att.FileName);
byte[] MyData = new byte[att.AttachReq.Length];
using (FileStream fs = new FileStream(physicalPath, FileMode.Create, FileAccess.Write))
{
MyData = att.AttachReq;
fs.Write(MyData, 0, System.Convert.ToInt32(att.AttachReq.Length));
fs.Close();
fs.Dispose();
}
return File(physicalPath, "application/octet-stream", att.FileName);
}
The method works fine on IPhone (safari), Android (Opera and Dolphin) and Windows Mobile (IE)...
However user encounter problem when accessing from Blackberry (default browser) and Andoid (default browser). They always cannot download the file requested. Somehow it always failed, or download unsuccessfull.
moh.mrt
0 Points
4 Posts
Download problem on Blackberry and Android Browser
Nov 21, 2012 11:28 AM|LINK
Hi All,
I've trouble with my web apps, im using MVC3, here is my scratch code :
public FileResult ViewPRAttachAjax(Int64 Id) { //String StrCode = Request["q"].ToString(); //Int64 Id = Int64.Parse(StrCode); //nulis ke file RequsitionAttachmentRepository reqAttach = new RequsitionAttachmentRepository(); RequsitionAttachmentViewModel att = reqAttach.GetAttachment(Id).SingleOrDefault(); var physicalPath = Path.Combine(Server.MapPath("~/Content/Files/"), att.FileName); byte[] MyData = new byte[att.AttachReq.Length]; using (FileStream fs = new FileStream(physicalPath, FileMode.Create, FileAccess.Write)) { MyData = att.AttachReq; fs.Write(MyData, 0, System.Convert.ToInt32(att.AttachReq.Length)); fs.Close(); fs.Dispose(); } return File(physicalPath, "application/octet-stream", att.FileName); }The method works fine on IPhone (safari), Android (Opera and Dolphin) and Windows Mobile (IE)...
However user encounter problem when accessing from Blackberry (default browser) and Andoid (default browser). They always cannot download the file requested. Somehow it always failed, or download unsuccessfull.
I've tried many ways, also i change the code
into
Is there anybody has suggestion how can i solve my problem ??
roopeshreddy
All-Star
20155 Points
3328 Posts
Re: Download problem on Blackberry and Android Browser
Nov 21, 2012 02:52 PM|LINK
Hi,
Which BlackBerry OS are you using? Did you tried in BB OS 7?
How about Android? Did you tried in Ice Cream Sanwich(4.0) OS?
Moreover, FileDownload also depends on the network speed of the device and some devices doesn't support downloading large files!
Hope it helps u...
Roopesh Reddy C
Roopesh's Space
moh.mrt
0 Points
4 Posts
Re: Download problem on Blackberry and Android Browser
Nov 22, 2012 01:31 AM|LINK
Hi roopeshreddy,
Various version of BB, I had tried with BB OS 5, 6, and 7. Also the android, using Gingerbread, Honeycomb, ICS, however it didnt works.
for your information, i had tried with small file size.
any suggestion?
roopeshreddy
All-Star
20155 Points
3328 Posts
Re: Download problem on Blackberry and Android Browser
Nov 22, 2012 05:34 AM|LINK
Hi,
Check this thread - http://stackoverflow.com/questions/5900604/downloading-files-in-an-android-3-0-browser-from-my-asp-net-site
Moreover, instead of programatically pushing the file to the device, try providing a link to the file, like this -
Hope it helps u...
Roopesh Reddy C
Roopesh's Space