How to open a Snapshot file from ASP.NET

S

Steven Thomas

I am working on a ASP.NET application using VB.NET.
I have a function that creates a snapshot file on a separate server
and passes a path back to the webpage. Now I want to display the
snapshot. If I cut and paste the path into the browser it opens
snapshot viewer. Exactly what I want. However, if I
response.redirect to the path, I get a error that the file can not be
found. If I response.redirect to "file:"+path It opens the snapshot
in the browser, however you loose most of the controls in shapshot
viewer. You can no longer print or email from the file menu.

Here is the path that gets generated:

\\WPGA030ADOR1\GPRptSrv\TSWPRDSQL\RptOutput\11-18-04
103139_40904a53_29dc_432f_8f33_322e196ef503.snp

When the redirect happens it shows up in the browser as
http://WPGA030ADOR1/GPRptSrv/TSWPRD...4604_137641bd_492c_41bf_901c_20f99219789a.snp
And
file:\\WPGA030ADOR1\GPRptSrv\TSWPRDSQL\RptOutput\11-18-04
103139_40904a53_29dc_432f_8f33_322e196ef503.snp


When I cut and paste IE shows a folder icon in the address bar. When
the redirect happens it shows an IE/HTML page icon, when the second
redirect happens it shows a snapshot file icon?

Any ideas on how to redirect to the file as if you where cutting and
pasting??
 
E

Eliahu

well...
You can make your page generate pretty much any content when you output it
to HttpResponse.OutputStream (you can get there from
Page.Response.OutputStream). I don't have the example right now, but
HttpResponse.OutputStream is of type Stream (see msdn). It means, you can
use write to it the same way you write to your text file.

In practice you would:

1. Open a stream S to your snapshot (don't forget to use Server.MapPath)
2. Copy the content of the S to Response.OutputStream (use the example of
copying files).
3. Close S
4. You're done.
 

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,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top