GIDForums  

Go Back   GIDForums > Computer Programming Forums > .NET Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
 
 
Thread Tools Search this Thread Rating: Thread Rating: 3 votes, 5.00 average.
  #1  
Old 14-Nov-2006, 07:32
aie0 aie0 is offline
Member
 
Join Date: Dec 2004
Posts: 246
aie0 is a jewel in the roughaie0 is a jewel in the rough

Download file through SSL


I need to put some xls files ( ~50kB) on aspx so that user could download through ssl.
I used:
C-SHARP / C# Code:
Response.Clear();
Context.Response.ContentType = "application/vnd.ms-excel";
Response.WriteFile(path);

// or 

Response.Clear();
Context.Response.ContentType = "application/vnd.ms-excel";
Response.TransmitFile(path);

// or 

                Context.Response.Buffer = false;
                System.IO.FileStream inStr = null;
                byte[] buffer = new byte[1024];
                long byteCount;

                inStr = System.IO.File.OpenRead(path);
                while ((byteCount = inStr.Read(buffer, 0, buffer.Length)) > 0)
                {
                    if (Context.Response.IsClientConnected)
                    {
                     Context.Response.OutputStream.Write(buffer, 0,
                                                                                 buffer.Length);
                        Context.Response.Flush();
                    }
                }

All 3 versions work on regular http but not on https. Regular internet explorer file download dialog appears with a part of request string instead of file name:
and when I push open/save it says Internet explorer cannot download from
...11-03@date1x=200-11-14 form <site name>
where "11-03@date1x=200-11-14" is part of request string of aspx.
Does some one have any solution?
  #2  
Old 14-Nov-2006, 12:32
erniegerdie erniegerdie is offline
Awaiting Email Confirmation
 
Join Date: Feb 2004
Location: England
Posts: 93
erniegerdie has a spectacular aura abouterniegerdie has a spectacular aura about

Re: download file through ssl


The code you have placed on the previous post.

Is that in a ASPX page or httphandler thats sitting on HTTPS not HTTP?

Also, how is this page being called? I.e directly from the user or via another form (if so is that also on HTTPS?) etc...
  #3  
Old 15-Nov-2006, 00:33
aie0 aie0 is offline
Member
 
Join Date: Dec 2004
Posts: 246
aie0 is a jewel in the roughaie0 is a jewel in the rough

Re: download file through ssl


Quote:
The code you have placed on the previous post.
Is that in a ASPX page or httphandler thats sitting on HTTPS not HTTP?
Code is from aspx button handler.
I also put it in on_load method - same result
Quote:
Also, how is this page being called? I.e directly from the user or via another form (if so is that also on HTTPS?) etc...

Page is being called through login control navigateurl - so I guess server.transfrer or response.redirect

Interesting point that if I put the code in on_load of logIN page ( the first one to show) then it does work, so I guess it has something to with redirecting
  #4  
Old 15-Nov-2006, 02:08
aie0 aie0 is offline
Member
 
Join Date: Dec 2004
Posts: 246
aie0 is a jewel in the roughaie0 is a jewel in the rough
Thumbs up

Re: download file through ssl


Solved,
Response has to cleaned before sending a file. Probable ssl adds some staff to response which compromises the transfer.
C-SHARP / C# Code:
                Response.ClearHeaders();
                Response.ClearContent();
                Response.Clear();
                Context.Response.ContentType = "application/vnd.ms-excel";
                Context.Response.AddHeader("Content-Disposition",
                       "attachment;filename=" + name);
                Response.TransmitFile(path);
                Response.End();

Good question I guess - Does cleaning response disable ssl?
  #5  
Old 06-Jul-2012, 07:34
Kacyndra's Avatar
Kacyndra Kacyndra is offline
Member
 
Join Date: May 2005
Location: Maryland
Posts: 233
Kacyndra will become famous soon enough

Re: Download file through ssl


hi!

I am having the same issue, my code looks like:


C-SHARP / C# Code:
 HttpResponse httpResponse = Response;
        
            httpResponse.ClearHeaders();
            httpResponse.ClearContent();
            httpResponse.Clear();
            httpResponse.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
            httpResponse.AddHeader("content-disposition", "attachment;filename=\"asdf.xlsx\"");

i am unable to export to excel when using SSL in IE 8. am i missing something else?

thanks in advance!
__________________
Xrum!
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
CD Burner Help - Power Calibration Error.... JonBoy420 Computer Hardware Forum 112 02-Jun-2010 21:00
Airport Log program using 3D linked List : problem reading from file batrsau C Programming Language 11 29-Feb-2008 07:44
CD burner wont burn!! robertli55 Computer Hardware Forum 1 18-Jun-2004 10:53
Yet another CD burner problem: Lite-On LSC-24082K Erwin Computer Hardware Forum 1 22-May-2004 11:28
Force a file download dsmith Web Design Forum 3 03-Apr-2004 09:05

Network Sites: GIDNetwork · GIDApp · GIDBlog · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 08:35.


vBulletin, Copyright © 2000 - 2014, Jelsoft Enterprises Ltd.