Connecting Tech Pros Worldwide Forums | Help | Site Map

downloading file get empty from one server.

Frank
Guest
 
Posts: n/a
#1: Dec 5 '05
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


Daniel Fisher\(lennybacon\)
Guest
 
Posts: n/a
#2: Dec 5 '05

re: downloading file get empty from one server.


What about posting some code ...

--
Daniel Fisher(lennybacon)
http://www.lennybacon.com


"Frank" <Frank@discussions.microsoft.com> wrote in message
news:E2A89F95-9B8F-4140-A058-5030B0FB0E75@microsoft.com...[color=blue]
> 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
>[/color]


Frank
Guest
 
Posts: n/a
#3: Dec 5 '05

re: downloading file get empty from one server.


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:
[color=blue]
> What about posting some code ...
>
> --
> Daniel Fisher(lennybacon)
> http://www.lennybacon.com
>
>
> "Frank" <Frank@discussions.microsoft.com> wrote in message
> news:E2A89F95-9B8F-4140-A058-5030B0FB0E75@microsoft.com...[color=green]
> > 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
> >[/color]
>
>
>[/color]
Frank
Guest
 
Posts: n/a
#4: Dec 5 '05

re: downloading file get empty from one server.


Maybe here is not the correct place to post this question. Any suggestion
that which newsgroup I should put ?
Thanks
"Frank" wrote:
[color=blue]
> 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:
>[color=green]
> > What about posting some code ...
> >
> > --
> > Daniel Fisher(lennybacon)
> > http://www.lennybacon.com
> >
> >
> > "Frank" <Frank@discussions.microsoft.com> wrote in message
> > news:E2A89F95-9B8F-4140-A058-5030B0FB0E75@microsoft.com...[color=darkred]
> > > 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
> > >[/color]
> >
> >
> >[/color][/color]
agapeton@gmail.com
Guest
 
Posts: n/a
#5: Dec 6 '05

re: downloading file get empty from one server.


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/

Frank
Guest
 
Posts: n/a
#6: Dec 6 '05

re: downloading file get empty from one server.


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

Frank

"agapeton@gmail.com" wrote:
[color=blue]
> 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/
>
>[/color]
Alexander Greiner
Guest
 
Posts: n/a
#7: Dec 6 '05

re: downloading file get empty from one server.


Hi Frank,

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

Regards,
Alex

"Frank" wrote:
[color=blue]
> Thanks David. I'll test with this. But could you explain why the code is not
> work only on one server?
>
> Frank
>
> "agapeton@gmail.com" wrote:
>[color=green]
> > 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/
> >
> >[/color][/color]
Frank
Guest
 
Posts: n/a
#8: Dec 7 '05

re: downloading file get empty from one server.


Problem still there! I uses this code and tested. I got same empty file.
Any idea ?
Thanks,
Frank

"agapeton@gmail.com" wrote:
[color=blue]
> 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/
>
>[/color]
Closed Thread