Solved

MemoryStream as input to file download?

Posted on 2006-11-30
8
1,464 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
Comment Utility
Make sure that your aspx page doesn't have any HTML markup.
0
 
LVL 2

Author Comment

by:codequest
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 2

Author Comment

by:codequest
Comment Utility
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
Comment Utility
Still working my way back to this...
0
 
LVL 2

Author Comment

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

Expert Comment

by:Bob Learned
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

763 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

8 Experts available now in Live!

Get 1:1 Help Now