473,382 Members | 1,442 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,382 software developers and data experts.

downloading file get empty from one server.

Hi,
On one of my server, downloading file by clicking a button give empt
file. On the other servers work perfectly. Is any idea ? What should be
change in IIS Metabase setting?
After click the button on an aspx page, IE prompts the users whether they
want to open, save or cancel the download with correct name. No matter click
open or save, it started download and transfered 0 byte. I checked the server
side it did created the file with correct contents. The code is same as those
many posted here.
Thanks in advance.
Frank

Dec 5 '05 #1
7 4608
What about posting some code ...

--
Daniel Fisher(lennybacon)
http://www.lennybacon.com
"Frank" <Fr***@discussions.microsoft.com> wrote in message
news:E2**********************************@microsof t.com...
Hi,
On one of my server, downloading file by clicking a button give empt
file. On the other servers work perfectly. Is any idea ? What should be
change in IIS Metabase setting?
After click the button on an aspx page, IE prompts the users whether they
want to open, save or cancel the download with correct name. No matter
click
open or save, it started download and transfered 0 byte. I checked the
server
side it did created the file with correct contents. The code is same as
those
many posted here.
Thanks in advance.
Frank

Dec 5 '05 #2
Code runs good on other servers. But here is the code:

Response.AddHeader("Content-Type", "application/csv")
Response.AddHeader("Content-Disposition",
"attachment;filename=" + fileName + ";")

Dim Fs As FileStream = New FileStream(Server.MapPath("~/" &
fileName), FileMode.Open)
Dim FileSize As Long = Fs.Length
Dim bBuffer() As Byte = New Byte(FileSize) {}
Fs.Read(bBuffer, 0, Convert.ToInt32(FileSize))
Fs.Close()

Response.BinaryWrite(bBuffer)
Response.Flush()
Response.Close()

Thanks,
Frank
"Daniel Fisher(lennybacon)" wrote:
What about posting some code ...

--
Daniel Fisher(lennybacon)
http://www.lennybacon.com
"Frank" <Fr***@discussions.microsoft.com> wrote in message
news:E2**********************************@microsof t.com...
Hi,
On one of my server, downloading file by clicking a button give empt
file. On the other servers work perfectly. Is any idea ? What should be
change in IIS Metabase setting?
After click the button on an aspx page, IE prompts the users whether they
want to open, save or cancel the download with correct name. No matter
click
open or save, it started download and transfered 0 byte. I checked the
server
side it did created the file with correct contents. The code is same as
those
many posted here.
Thanks in advance.
Frank


Dec 5 '05 #3
Maybe here is not the correct place to post this question. Any suggestion
that which newsgroup I should put ?
Thanks
"Frank" wrote:
Code runs good on other servers. But here is the code:

Response.AddHeader("Content-Type", "application/csv")
Response.AddHeader("Content-Disposition",
"attachment;filename=" + fileName + ";")

Dim Fs As FileStream = New FileStream(Server.MapPath("~/" &
fileName), FileMode.Open)
Dim FileSize As Long = Fs.Length
Dim bBuffer() As Byte = New Byte(FileSize) {}
Fs.Read(bBuffer, 0, Convert.ToInt32(FileSize))
Fs.Close()

Response.BinaryWrite(bBuffer)
Response.Flush()
Response.Close()

Thanks,
Frank
"Daniel Fisher(lennybacon)" wrote:
What about posting some code ...

--
Daniel Fisher(lennybacon)
http://www.lennybacon.com
"Frank" <Fr***@discussions.microsoft.com> wrote in message
news:E2**********************************@microsof t.com...
Hi,
On one of my server, downloading file by clicking a button give empt
file. On the other servers work perfectly. Is any idea ? What should be
change in IIS Metabase setting?
After click the button on an aspx page, IE prompts the users whether they
want to open, save or cancel the download with correct name. No matter
click
open or save, it started download and transfered 0 byte. I checked the
server
side it did created the file with correct contents. The code is same as
those
many posted here.
Thanks in advance.
Frank


Dec 5 '05 #4
I feel kinda weird about the combination of csv and binary...

Here's code from something I wrote a few weeks ago... it's .NET 2.0 and
C#, so you will have to play, but it works great.

string fullpath = @"c:\windows\temp\" + excelFileName;

using (FileStream fs = new FileStream(fullpath,
FileMode.CreateNew, FileAccess.Write, FileShare.Write)) {
fs.Write(file, 0, file.Length);
}

// FileInfo fileInfo = new FileInfo(fullpath);
Response.Buffer = true;
Response.Clear( );
Response.ClearContent( );
Response.ClearHeaders( );

Response.AddHeader("Content-Disposition", "attachment;
filename=" + "AutoGeneratedReport.xls");
Response.AddHeader("Content-Length", file.Length.ToString(
));
Response.ContentType = "application/vnd.ms-excel";
Response.WriteFile(fullpath);
Response.Flush( );

David Betz
http://davidbetz.net/dynamicbliss/
http://davidbetz.net/winfx/

Dec 6 '05 #5
Thanks David. I'll test with this. But could you explain why the code is not
work only on one server?

Frank

"ag******@gmail.com" wrote:
I feel kinda weird about the combination of csv and binary...

Here's code from something I wrote a few weeks ago... it's .NET 2.0 and
C#, so you will have to play, but it works great.

string fullpath = @"c:\windows\temp\" + excelFileName;

using (FileStream fs = new FileStream(fullpath,
FileMode.CreateNew, FileAccess.Write, FileShare.Write)) {
fs.Write(file, 0, file.Length);
}

// FileInfo fileInfo = new FileInfo(fullpath);
Response.Buffer = true;
Response.Clear( );
Response.ClearContent( );
Response.ClearHeaders( );

Response.AddHeader("Content-Disposition", "attachment;
filename=" + "AutoGeneratedReport.xls");
Response.AddHeader("Content-Length", file.Length.ToString(
));
Response.ContentType = "application/vnd.ms-excel";
Response.WriteFile(fullpath);
Response.Flush( );

David Betz
http://davidbetz.net/dynamicbliss/
http://davidbetz.net/winfx/

Dec 6 '05 #6
Hi Frank,

we have the same problem at our customers web server. :-( Were you able to
solve your problem? ;-)

Regards,
Alex

"Frank" wrote:
Thanks David. I'll test with this. But could you explain why the code is not
work only on one server?

Frank

"ag******@gmail.com" wrote:
I feel kinda weird about the combination of csv and binary...

Here's code from something I wrote a few weeks ago... it's .NET 2.0 and
C#, so you will have to play, but it works great.

string fullpath = @"c:\windows\temp\" + excelFileName;

using (FileStream fs = new FileStream(fullpath,
FileMode.CreateNew, FileAccess.Write, FileShare.Write)) {
fs.Write(file, 0, file.Length);
}

// FileInfo fileInfo = new FileInfo(fullpath);
Response.Buffer = true;
Response.Clear( );
Response.ClearContent( );
Response.ClearHeaders( );

Response.AddHeader("Content-Disposition", "attachment;
filename=" + "AutoGeneratedReport.xls");
Response.AddHeader("Content-Length", file.Length.ToString(
));
Response.ContentType = "application/vnd.ms-excel";
Response.WriteFile(fullpath);
Response.Flush( );

David Betz
http://davidbetz.net/dynamicbliss/
http://davidbetz.net/winfx/

Dec 6 '05 #7
Problem still there! I uses this code and tested. I got same empty file.
Any idea ?
Thanks,
Frank

"ag******@gmail.com" wrote:
I feel kinda weird about the combination of csv and binary...

Here's code from something I wrote a few weeks ago... it's .NET 2.0 and
C#, so you will have to play, but it works great.

string fullpath = @"c:\windows\temp\" + excelFileName;

using (FileStream fs = new FileStream(fullpath,
FileMode.CreateNew, FileAccess.Write, FileShare.Write)) {
fs.Write(file, 0, file.Length);
}

// FileInfo fileInfo = new FileInfo(fullpath);
Response.Buffer = true;
Response.Clear( );
Response.ClearContent( );
Response.ClearHeaders( );

Response.AddHeader("Content-Disposition", "attachment;
filename=" + "AutoGeneratedReport.xls");
Response.AddHeader("Content-Length", file.Length.ToString(
));
Response.ContentType = "application/vnd.ms-excel";
Response.WriteFile(fullpath);
Response.Flush( );

David Betz
http://davidbetz.net/dynamicbliss/
http://davidbetz.net/winfx/

Dec 7 '05 #8

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

Similar topics

1
by: Roy | last post by:
Hi, I have a problem that I have been working with for a while. I need to be able from server side (asp.net) to detect that the file i'm streaming down to the client is saved...
4
by: Joe | last post by:
I'm hosting my web service on a Windows 2003 box which is remotely located. When trying to add a web reference to a C# project I get an error message 'There was an error downloading...
1
by: just.starting | last post by:
Hi, My dot net client downloads files and checks for any new files time to time. The server is apache2.0.53 server. So what happens is that my file download thing works fine if I dont try to call...
3
by: just.starting | last post by:
Hi, My dot net client downloads files and checks for any new files time to time. The server is apache2.0.53 server. So what happens is that my file download thing works fine if I dont try to call...
23
by: Doug van Vianen | last post by:
Hi, Is there some way in JavaScript to stop the downloading of pictures from a web page? Thank you. Doug van Vianen
2
by: Tomas Martinez | last post by:
Hi there! I'm trying to download a file in my asp.net web, but when downloading it from a Firefox browser, instead of downloading the example.exe file, it's downloading example.exe.htm. My code...
3
by: Chuck Renner | last post by:
Please help! This MIGHT even be a bug in PHP! I'll provide version numbers and site specific information (browser, OS, and kernel versions) if others cannot reproduce this problem. I'm...
3
by: Obi | last post by:
HI all, I have a problem during download file with Internet Explorer 6. I use this script: header('Pragma: public'); header('Expires: 0'); header('Cache-Control: must-revalidate,...
1
by: Muddasir | last post by:
Hello everyone. I am facing problem in downloading .xls file. I generate report and save data in excel sheet on server. and once user click the 'save data in excel format', an excel sheet is...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.