Solved

Streaming SVG in an ASPX page

Posted on 2006-11-18
11
481 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

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
 

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

816 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

9 Experts available now in Live!

Get 1:1 Help Now