Saving content of dynamic page

J

jad101

I have an asp.net web page that:

1. Shows a message
2. Posts back (using javascript)
3. Reads contents of a file
4. response.write the contents of the file to the browser

My issue is this: If a user hits this page and decides to save the
page for offline browsing, they are not saving the output of the
response.write, but instead the html that shows the message and calls
the refresh.

How can I allow the user to save the current content of the page,
without hitting the server again for the dynamically created content?

Thanks in advance,

Jay
 
K

Kevin Spencer

Interesting problem Jay. Haven't encountered that one before. I think the
problem is related to the fact that the page, after PostBack is a Form
results page (as far as the browser knows). So the browser requests the page
afresh. A possible workaround would be to put the contents of the file (a
text file?) into a Session variable, and create a second page that displays
the contents of the Session variable. Then Response.Redirect to the second
page. This would enable the browser to make a fresh request for the second
page, which would then reload the text from the Session variable and display
it as you want it to be saved.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.
 
S

Steve C. Orr [MVP, MCSD]

Maybe you can use some code like this:

Response.Clear()
Response.ContentType = Whatever
Response.Writefile("c:\whatever.doc")
Response.AddHeader("Content-Disposition", _
"inline;filename=whatever.doc")
Response.End()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top