Solved

MemoryStream as input to file download?

Posted on 2006-11-30
8
1,467 Views
Last Modified: 2009-12-16
I tried using a memorystream as input to an xml file download, so I wouldn't have to create a disk file (to then delete)....

            Response.Clear()
            Response.AddHeader("Content-Disposition", "attachment; filename=" & varFileName)
            Response.ContentType = "text/XML"
            '    Response.WriteFile(varFilePath & varFileName)  < the alt way to do it

            ''---  use memorystream
            varMemTab.Position = 0
            Dim wrkStreamReader As New StreamReader(varMemTab, Encoding.UTF8)
            Dim content As String = wrkStreamReader.ReadToEnd()
            ''---- do the write
            Response.WriteFile(content)

....but it gave an http exception error like it was processing the markup in the Response.WriteFile(content) statement.

Might there be a way to make this work?

Any suggestions would be appreciated.

Thanks!

0
Comment
Question by:codequest
8 Comments
 
LVL 9

Assisted Solution

by:kraffay
kraffay earned 100 total points
ID: 18049272
Make sure that your aspx page doesn't have any HTML markup.
0
 
LVL 2

Author Comment

by:codequest
ID: 18049701
Thanks for input.  I'll give that a try a little later and postback.
0
 
LVL 15

Assisted Solution

by:Solar_Flare
Solar_Flare earned 200 total points
ID: 18049723
also end the response stream after you have written your file to it


Response.End
0
 
LVL 25

Accepted Solution

by:
nauman_ahmed earned 200 total points
ID: 18054518
WriteFile save the file to disk. To send the file to browser as a download, you have to download the file as a byte array. See if the following helps:

Re: Force File Download XML Problem
http://www.thescripts.com/forum/thread288016.html

--Nauman.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 2

Author Comment

by:codequest
ID: 18155938
Thanks for input.   Still working my way back to this one.  I'll keep it alive with posts until I fully resolve.
0
 
LVL 2

Author Comment

by:codequest
ID: 18209766
Still working my way back to this...
0
 
LVL 2

Author Comment

by:codequest
ID: 18342915
Still working on this, should get to it soon...
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 18461332
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I will leave the following recommendation for this question in the Cleanup topic area:
   Accept: nauman_ahmed {http:#18054518}

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

TheLearnedOne
EE Cleanup Volunteer
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
CheckboxList Object reference not set to an instance of an object. 16 33
Asp.net mvc foreach 3 35
Need a starter for ETL protocol? 4 43
Code works but it's slow 24 44
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now