Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 504
  • Last Modified:

Streaming SVG in an ASPX page

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
Pete2003
Asked:
Pete2003
  • 7
  • 4
1 Solution
 
ozymandiasCommented:
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
 
ozymandiasCommented:
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
 
ozymandiasCommented:
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Pete2003Author Commented:
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
 
ozymandiasCommented:
If you look at this article and examples can you see the graphics ?

http://www.4guysfromrolla.com/webtech/091401-1.shtml
0
 
Pete2003Author Commented:
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
 
ozymandiasCommented:
Very weird....
0
 
Pete2003Author Commented:
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
 
ozymandiasCommented:
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
 
Pete2003Author Commented:
That worked 100% thanks :)
0
 
ozymandiasCommented:
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 7
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now