Saving Aspx Output to File On Server

G

Guest

We have a web application written in ASP.NET using C#. The application
renders Maps using the SVG (scalable vector graphics) standard. Normally the
SVG is sent direct to the user from the Aspx page. However we wish to save
the output to a file on the server for processing i.e conversion to a raster
file etc, any ideas how to do this?
 
G

Guest

Hi Bruce... I think you need to override the render method as below
(untested). You may be better off using an httpHandler to create your SVG
output though.

HTH jd

Protected Overrides Sub Render(ByVal writer As HtmlTextWriter)

'create stream to store output
Dim myStream As New IO.MemoryStream

'create writer
Dim myWriter As New HtmlTextWriter(New IO.StreamWriter(myStream))

' use your writer to render the page
MyBase.Render(myWriter)


' get a reader to read your stream
Dim myReader As New IO.StreamReader(myStream)
myReader.BaseStream.Position = 0

' read it into a string
Dim mySvgContent As String = myReader.ReadToEnd
'close your stream and writer
myReader.BaseStream.Close()
myReader.Close()

'persist to disk
Dim fs As New IO.FileStream("c:\myoutput.svg", IO.FileMode.Create)
Dim fsw As New IO.StreamWriter(fs)
fsw.Write(mySvgContent)
fs.Close()
fsw.Close()


'write to default writer to render to screen
writer.Write(mySvgContent)
End Sub
 
G

Guest

You are rendering the output to somewhere (most likely a location in memory).
Prior to sending to the client, use a stream object to stream the bytes from
memory to a file.

NOTE: I am not familiar with working with scalable vector graphics, so I am
not sure exactly how it is represented when you build it, but the concept is
the same whether working with strings or byte arrays. You have to stream out
of your "variable" name into a stream object and finally write to a file.

possible links:
http://weblogs.asp.net/donxml/archive/2003/05/12/6915.aspx
http://www.codeproject.com/csharp/svgnet.asp
http://www.codeproject.com/csharp/SvgPad.asp

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top