title: creating an Image from SVG on the server using asp.net MVC?
body: <p>I am trying to create an image from an svg that I pass into my controller from the client side.</p>
  
  <p>the svg is being passed in thourgh a posted form's hidden input.</p>
  
  <p>Controller:</p>
  
  <pre><code>[HttpPost, ValidateInput(false)]
  public ActionResult GetChartImage(string svgString)
  {
      byte[] imageBytes;
  
      var bytes = Encoding.ASCII.GetBytes(svgString);
  
      using (var stream = new MemoryStream(bytes))
      {
          var svgDocument = SvgDocument.Open(stream);
          var bitmap = svgDocument.Draw();
          bitmap.Save(stream, ImageFormat.Png);
          imageBytes = stream.ToArray();
      }
  
      return File(new MemoryStream(imageBytes), "image/png");
  }
  </code></pre>
  
  <p>the problem is that when the process finishes the new webpage that was opened as a result of posting the form, doesn't show the produced image:</p>
  
  <p><img src="https://i.stack.imgur.com/GjTlb.png" alt="enter image description here"></p>