By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,301 Members | 3,575 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,301 IT Pros & Developers. It's quick & easy.

Saving Aspx Output to File On Server

P: n/a
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?
Nov 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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

"Bruce Ramsey" wrote:
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?

Nov 19 '05 #2

P: n/a
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/archiv...5/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!
***************************
"Bruce Ramsey" wrote:
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?

Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.