Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Can not download large file using Ultidev Cassini
pepe
#1 Posted : Wednesday, March 17, 2010 8:21:25 PM(UTC)
Groups: Member
Joined: 3/17/2010(UTC)
Posts: 3
Location: Jakarta

I have a download button in my website, it can download small size file, but when file size is large, it done nothing, event when i debug the download button even, it can'be trace, the breakpoint is not hit,

then i change the web server, i use MS IIS
download is running well (small or large file) when using MS IIS
Ultidev Team
#2 Posted : Thursday, March 18, 2010 5:40:15 AM(UTC)
Ultidev Team

Groups: Administration
Joined: 11/3/2005(UTC)
Posts: 2,253

Thanks: 28 times
Was thanked: 60 time(s) in 59 post(s)
Hi there!

We are sorry for the inconvenience.

Does the link point to a file, like <a href="somefile.txt">Download the file</a>, or do you actually have a button with server-side OnClick handler? If you have the button, could you please post the code that handles the click and sends file over to the client. Also please let us know where in the sample is the breakpoint that is not hit.

Best regards,
UltiDev Team.
Please donate at http://www.ultidev.com/products/Donate.aspx to help us improve our products.
pepe
#3 Posted : Wednesday, March 24, 2010 8:05:07 PM(UTC)
Groups: Member
Joined: 3/17/2010(UTC)
Posts: 3
Location: Jakarta

I have a Button with server-side OnClick handler, here are the codes
protected void btnDownload_Click(object sender, ImageClickEventArgs e) ***I PUT BREAKPOINT HERE***
{
try
{
string fileName = "ProductAvail_" + DateTime.Now.ToString("yyyyMMdd") + "_" + DateTime.Now.ToString("hmmsstt");
string directory = Request.PhysicalApplicationPath + "Download/";
string serverPath = HttpContext.Current.Request.Url.AbsoluteUri.Substring(0, HttpContext.Current.Request.Url.AbsoluteUri.LastIndexOf("/"));

if (!System.IO.Directory.Exists(directory))
System.IO.Directory.CreateDirectory(directory);
DataTable table = (DataTable)ViewState["dtTemp2"];
ExcelConvertor ex = new ExcelConvertor();
ex.Convert(table, directory + fileName + ".xls");
string url = "../download/download.aspx?fp=" + directory + fileName + ".xls";
Response.Redirect(url);

}
catch (Exception exx)
{
lblMsg.Text = exx.Message;
}
}

Code in download.aspx(page load event)

string path = Request.QueryString["fp"].ToString();
FileInfo file = new FileInfo(path);
if (file.Exists)
{


System.IO.Stream iStream = null;
// Buffer to read 10K bytes in chunk:
byte[] buffer = new Byte[10000];
// Length of the file:
int length;
// Total bytes to read:
long dataToRead;
// Identify the file to download including its path.
string filepath = file.FullName; //"\\\\portnumbria\\Exceptions\\09012009_Exception_AccountOfficerUnitCasa.txt";

// Identify the file name.
string filename = System.IO.Path.GetFileName(filepath);

try
{
// Open the file.
iStream = new System.IO.FileStream(filepath, System.IO.FileMode.Open,
System.IO.FileAccess.Read, System.IO.FileShare.Read);

// Total bytes to read:
dataToRead = iStream.Length;

Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);

// Read the bytes.
while (dataToRead > 0)
{
// Verify that the client is connected.
if (Response.IsClientConnected)
{
// Read the data in buffer.
length = iStream.Read(buffer, 0, 10000);

// Write the data to the current output stream.
Response.OutputStream.Write(buffer, 0, length);

// Flush the data to the HTML output.
Response.Flush();

buffer = new Byte[10000];
dataToRead = dataToRead - length;
}
else
{
//prevent infinite loop if user disconnects
dataToRead = -1;
}
}
}
catch (Exception ex)
{
// Trap the error, if any.
Response.Write("Error : " + ex.Message);
}
finally
{
if (iStream != null)
{
//Close the file.
iStream.Close();
}
Response.Close();
}


Ultidev Team
#4 Posted : Thursday, March 25, 2010 5:20:29 AM(UTC)
Ultidev Team

Groups: Administration
Joined: 11/3/2005(UTC)
Posts: 2,253

Thanks: 28 times
Was thanked: 60 time(s) in 59 post(s)
Hi there.

There is nothing obviously wrong with this code. If you can hit the breakpoint in the IIS, then you should have been able to hit the same breakpoint under UltiDev Cassini. Are you able to hit any breakpoints when running your application under Cassini?

Best regards,
UltiDev Team.
Please donate at http://www.ultidev.com/products/Donate.aspx to help us improve our products.
pepe
#5 Posted : Sunday, March 28, 2010 4:33:05 PM(UTC)
Groups: Member
Joined: 3/17/2010(UTC)
Posts: 3
Location: Jakarta

I can hit any breakpoint under Cassini , download event handler is hit too, if file size is small, download is running well,
but when the file size is large, it done nothing, page become like hanging, click any button don't action anything, must refresh the page to become normal again.
Ultidev Team
#6 Posted : Monday, March 29, 2010 8:55:32 AM(UTC)
Ultidev Team

Groups: Administration
Joined: 11/3/2005(UTC)
Posts: 2,253

Thanks: 28 times
Was thanked: 60 time(s) in 59 post(s)
Hi!

Are you able to put a breakpoint in the download.aspx and step through the code in the debugger? Was it possible to use the debugger to identify exact place where it hangs?

Best regards,
UltiDev Team.
Please donate at http://www.ultidev.com/products/Donate.aspx to help us improve our products.
Rss Feed  Atom Feed
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You can vote in polls in this forum.