title: ViewData entry fails to expand for creation of <embed>, <iframe>, and <object> in Razor view
body: <p>I am creating a simple CSHTML view to display a PDF file in an ASP.NET Core 2.0 MVC web application.  The local URL for the PDF file is stored in the database, and is passed to the view in ViewData.  I have tried to open and view the PDF file using iframe, embed, and object statements in the Razor view file, but all attempts produce only an empty frame, unless I hard-code the local URL in the view file.  If I hardcode the URL in the view file, it works every time.  It only fails when I attempt to pass the local URL in ViewData (see below).</p>
  
  <p><strong>EXAMPLE TEST CONTROLLER CODE</strong></p>
  
  <p><code>// Set the ViewData value for testing.</code></p>
  
  <p><code>// ViewData["ArticleURL"] = article.LinkToArticle; // Comment out for testing.</code></p>
  
  <p><code>ViewData["ArticleURL"] = "/Articles/test.pdf";  // Local URL to PDF file.</code></p>
  
  <p><strong>EXAMPLE CSHTML CODE:</strong></p>
  
  <p>// This works for iframe, with the SRC hardcoded in the view...</p>
  
  <p><code>&lt;iframe src="~/Articles/test.pdf"&gt;&lt;/iframe&gt;</code></p>
  
  <p>// But fails, as expanded ViewData...</p>
  
  <p><code>&lt;iframe src="@ViewData["ArticleURL"]"&gt;&lt;/iframe&gt;</code></p>
  
  <p>// This works for embed, with SRC hardcoded in View...</p>
  
  <p><code>&lt;embed src="~/Articles/test.pdf" type="application/pdf" /&gt;</code></p>
  
  <p>// But fails, as expanded ViewData...</p>
  
  <p><code>&lt;embed src="@ViewData["ArticleURL"]" type="application/pdf" /&gt;</code></p>
  
  <p>// This works for object, with DATA hardcoded in the View...</p>
  
  <p><code>&lt;object data="~/Articles/test.pdf" type="application/pdf"&gt;&lt;/object&gt;</code></p>
  
  <p>// But fails, as expanded ViewData...</p>
  
  <p><code>&lt;object data="@ViewData["ArticleURL"]" type="application/pdf"&gt;&lt;/object&gt;</code></p>
  
  <p><strong>What would prevent @ViewData from correctly expanding to the string representing the local URL in the Object, Embed, or IFrame tags?</strong></p>
  
  <p>NOTE: I checked the ViewData value in debug, and it contains the local URL when the embed, iframe, and object statements are executed at runtime, but the view only displays an empty frame, and doesn't generate any errors or warnings.  Any ideas?  Thanks in advance for your help and patience!</p>