title: ASP.NET Core MVC : load file inside Razor page
body: <p>I am trying to make the terms and conditions page form my site. However, I am trying to provide the terms and conds page in the language the user prefers like Microsoft (they have this en-US prefix in their URL).</p>
  <p>I managed to create separate HTML folders in my <code>wwwroot</code> like <code>terms.en-US.html</code> and <code>terms.fr-CA</code> etc.</p>
  <p>I also created a controller named <code>FilesController</code> and it looks like this:</p>
  <pre><code>public class FilesController : Controller
  {
      [Route(&quot;Files/{language}/Terms&quot;)]
      public IActionResult Terms(string language)
      {
          ViewData[&quot;lang&quot;] = language;
          return View();
      }
  } 
  </code></pre>
  <p>And this is the <code>Terms.cshtml</code> file (so far):</p>
  <pre><code>@{
     Layout= &quot;_HomeLayout&quot;;
  }
  @Html.Raw(System.IO.File.ReadAllText(System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(),&quot;../files/documents/terms_and_conditions/&quot; + @ViewData[&quot;lang&quot;] + &quot;.html&quot;)));
  </code></pre>
  <p>But obviously it doesnt work. How can I manage this?</p>
  <p>PS: the only reason I am trying to add <em>html</em> into <em>cshtml</em> file is to benefit from the <em>layout</em> feature. Otherwise I would have directly return the html file in the controller like this:</p>
  <pre><code>public IActionResult Terms()
  {
      return File(&quot;~/files/documents/terms_and_conditions/tr-TR.html&quot;, &quot;text/html&quot;);
  }
  </code></pre>