title: mvc razor with @html.actionurl in database stored HTML
body: <p>I have been googlin' for a long while and have not quite found what I need. This is our scenario.</p>
  <p>We have an MVC4 app with Razor. On one screen we are using the Telerik Editor control to save text and images. These are formatted as HTML and stored in the database. The images are stored as byte[] data and the html src &quot;path&quot; is updated with the distinct file name.</p>
  <p>Later a user comes and wants to view the data. Because any images are stored in the database, I thought I could use the example found here <a href="https://stackoverflow.com/questions/7560830/convert-byte-array-to-image-and-display-in-razor-view">Convert Byte Array to image and display in Razor View</a> and I would update the  tag in the HTML with the  tag with a Url.Action and then render all that HTML to the screen.</p>
  <p>A sample of my dynamically generated html code after the image tag is replaced is</p>
  <pre><code>&lt;p&gt;testing the image blah&lt;/p&gt;&lt;p&gt;&lt;img src=&quot;@Url.Action(&quot;getImg&quot;, &quot;Responses&quot;, new { id = 1 }) &quot; alt=&quot;Response Image&quot; /&gt; &lt;/p&gt;
  </code></pre>
  <p>BUT If I use HTML.Raw(Text), it does not process the image. If I just copy that image tag right into the view, works great.</p>
  <p>My question is, how can I render dynamically created HTML with Razor syntax code on a View properly?</p>
  <p>*************** more details ***********</p>
  <p>A few more details to help clarify what I'm doing.
  I have two models Response and ResponseImages.</p>
  <pre><code>public class Response : TrackableBase 
  {
      [Key]
      public int ResponseId { get; set; }
      public string Subject{ get; set; }
      
      [MaxLength]
      public string Text { get; set; }
      
      public virtual ICollection&lt;ResponseImage&gt; ResponseImages { get; set; }
  }
  
  public class ResponseImage : TrackableBase
  {
      [Key]
      public int ResponseImageId { get; set; }
      
      public int ResponseId { get; set; }
      [ForeignKey(&quot;ResponseId&quot;)]
      public virtual Response Response { get; set; }
      
      public string FilePath { get; set; }
      public string FileName { get; set; }
      public string FileExtension { get; set; }
      public byte[] Image {get; set;}
  }
  </code></pre>
  <p>Response.Text stores HTML from the Telerik editor. I use HTMLAgilitypack to loop through all images in the HTML and from these I create the ResponseImage records, with the ResponseImage.FilePath being what I use as the link back to the HTML code stored in Response.Text (all images are updated with a distinct name/path).</p>
  <p>On my Details.cshtml screen I want to view the details of the Response.Text.
  From the database my Response.Text looks like this:</p>
  <pre><code>&lt;p&gt;hjjk&lt;/p&gt;&lt;p&gt;
  &lt;img alt=&quot;&quot; height=&quot;144&quot; src=&quot;/Content/Editor_Images/UserFiles/JKULBIDA/Images/Koala_635019802303066655.jpg&quot; width=&quot;164&quot;&gt;&lt;/p&gt;
  </code></pre>
  <p>BUT, because I am storing images in the database and not the file system, I again use HTMLAgility pack and update all of the image tags with the Razor syntax for using @Url.Action. My new HTML looks like this</p>
  <pre><code>&lt;p&gt;hjjk&lt;/p&gt;&lt;p&gt;&lt;img src=&quot;@Url.Action(&quot;getImg&quot;, &quot;Responses&quot;, new { id = 4 }) &quot; alt=&quot;Response Image&quot; /&gt; &lt;/p&gt;
  </code></pre>
  <p>FINALLY, on my View, I want to display my data, but also have the HTML formatted properly. So I call @Html.Raw(Model.Text) and my image tag doesn't work :(</p>
  <p>***** end of update ****</p>
  <p>Thanks in advance, as I'm super stuck on this.</p>