Solved

Streaming SVG in an ASPX page

Posted on 2006-11-18
11
477 Views
Last Modified: 2010-04-16
Hi All,

I need some help.

I have an ASPX Page. I would like to stream a simple polygon in SVG.

I'v tried MANY combinations but with no luck
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Clear();
            Response.ContentType = "image/svg+xml";
            Response.Write("<?xml version=\"1.0\" standalone=\"no\"?>");
            Response.Write("<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">");
            Response.Write("<svg width=\"12cm\" height=\"4cm\" viewBox=\"0 0 1200 400 xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">");
            Response.Write("<desc>Example polygon01 - star and hexagon</desc>");
            Response.Write("  <rect x=\"1\" y=\"1\" width=\"1198\" height=\"398\" fill=\"none\" stroke=\"blue\" stroke-width=\"2\" />");
            Response.Write("   <polygon fill=\"red\" stroke=\"blue\" stroke-width=\"10\" points=\"350,75  379,161 469,161 397,215 423,301 350,250 277,301 303,215 231,161 321,161\" />");
            Response.Write("</svg>");
            Response.End();
        }

I hav tried changing the type from image to text, taking out the XML and DOCTYPE and no luck.
I have the adobe viewer installed on IE6.


Any help appreciated
0
Comment
Question by:Pete2003
  • 7
  • 4
11 Comments
 
LVL 15

Expert Comment

by:ozymandias
ID: 17971081
Your svg is not well formed.
It may be the namespaces you have eclared.

This works ;

private void Page_Load(object sender, System.EventArgs e)
            {

                  Response.AddHeader("Content-Type","image/svg-xml");
                  Response.Write("<svg width=\"12cm\" height=\"4cm\" viewBox=\"0 0 1200 400\">");
                  Response.Write("<desc>Example polygon01 - star and hexagon</desc>");
                  Response.Write("  <rect x=\"1\" y=\"1\" width=\"1198\" height=\"398\" fill=\"none\" stroke=\"blue\" stroke-width=\"2\" />");
                  Response.Write("   <polygon fill=\"red\" stroke=\"blue\" stroke-width=\"10\" points=\"350,75  379,161 469,161 397,215 423,301 350,250 277,301 303,215 231,161 321,161\" />");
                  Response.Write("</svg>");
                  Response.End();


            }
0
 
LVL 15

Expert Comment

by:ozymandias
ID: 17971090
OK.
I have found the problem it is here :

 Response.Write("<svg width=\"12cm\" height=\"4cm\" viewBox=\"0 0 1200 400 xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">");

The attribute viewBox is not closed correctly you need it to be this :

 Response.Write("<svg width=\"12cm\" height=\"4cm\" viewBox=\"0 0 1200 400\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">");
0
 
LVL 15

Expert Comment

by:ozymandias
ID: 17971100
If you look in your browser when you mouse-over the page the svg plug-in has actually set the status bar test to :

not well formed : line 1, column 195.

However, it just shows this as info, not and error or even a warning.
0
 

Author Comment

by:Pete2003
ID: 17971225
Thanks for the replies, unfortunatelly nothing worked ...

I tried copy & paste from your 1st reply, al I get is a blank SVG plugin window.
I also tried fixing the viewbox window, no change
ALso I get nothing on the status line when I mouse over.

0
 
LVL 15

Expert Comment

by:ozymandias
ID: 17971389
If you look at this article and examples can you see the graphics ?

http://www.4guysfromrolla.com/webtech/091401-1.shtml
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

 

Author Comment

by:Pete2003
ID: 17971559
Ok this is very weird ...

The 1st demo shows nothing
<%Response.AddHeader "Content-Type","image/svg-xml"%>
<svg>
  <rect x="10" y="10" width="100" height="100"/>
</svg>



The 2nd one ...
<%Response.AddHeader "Content-Type","image/svg-xml"%>
<svg width="12cm" height="3.6cm" viewBox="0 0 1000 300"
     xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink">
  <defs>
    <path id="MyPath"
          d="M 100 200
             C 200 100 300   0 400 100
             C 500 200 600 300 700 200
             C 800 100 900 100 900 100" />
  </defs>
  <desc>Example toap01 - simple text on a path</desc>

  <use xlink:href="#MyPath" fill="none" stroke="red"  />
  <text font-family="Verdana" font-size="42.5" fill="blue" >
    <textPath xlink:href="#MyPath">
      <%
      Dim title
      title = "We go up, then we go down, then up again."
      If Request("title") <> "" Then
         title = Request("title")
      End If
      Response.Write title
      %>
    </textPath>
  </text>

  <!-- Show outline of canvas using 'rect' element -->
  <rect x="1" y="1" width="998" height="298"
        fill="none" stroke="blue" stroke-width="2" />
</svg>

Works 100% ... I tried uninstalling/rebooting and it's still the same
0
 
LVL 15

Expert Comment

by:ozymandias
ID: 17971616
Very weird....
0
 

Author Comment

by:Pete2003
ID: 17985408
It turns out that none of the SVGs are visible on the same machie as VS2005 is installed and I'm debugging from, but once I connect to the IIS site from a remote machine then I can see the SVG.

Does anybody know what to do to get it visible on the same machine?
0
 
LVL 15

Accepted Solution

by:
ozymandias earned 500 total points
ID: 17985838
There was a vulnerability in the svg rendering library in windows a while ago.
There was a delay in the patch from microsoft and the interim patch de-registered the faulty dll.
I do not know if this dll is used by the adobe plug-in at all but it may be that you need to patch-up your machine to get this fixed.
Or you could try re-registering the dll to see if it helps :

regsvr32 "%ProgramFiles%\Common Files\Microsoft Shared\VGX\vgx.dll"
0
 

Author Comment

by:Pete2003
ID: 17986492
That worked 100% thanks :)
0
 
LVL 15

Expert Comment

by:ozymandias
ID: 17986769
OK. However, you should make sure you are fully patched.
The Vulnerability in the SVG dll was a zero-day, remote code execution vulnerability.
If you are not patched you could get a nasty shock.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

760 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

19 Experts available now in Live!

Get 1:1 Help Now