0

I have a site with a layout, and am trying to render a plain Html file (that can change daily) inside of a view.

I have done partial views before and imagine that the solution would be similar, but after some trial and (and seraching) I have not found a way to include html files, just cshtml.

mmilan
  • 1,738
  • 8
  • 31
  • 57
  • Well a cshtml file technically renders as an html file. For what reason are you trying to do this? If you want to pull data from an html file you could grab the data with an ajax call... – Mike H. Nov 20 '13 at 14:59
  • its a file that another party puts together and it changes very often. the file is copied to a folder in IIS, overwriting the old file and then the information should show up without having to recompile anything. – mmilan Nov 20 '13 at 15:11
  • does this file have its own set of `` information? Or is it a literal partial file? – Brad Christie Nov 20 '13 at 15:12
  • @BradChristie it has information – mmilan Nov 20 '13 at 15:16
  • This work for you? : http://stackoverflow.com/q/18046247/391656 – Mr.Mindor Nov 20 '13 at 15:17

2 Answers2

1

Just put this in a blank cshtml file:

<div id="html">&nbsp;</div>

$("#html").load("PathToFile/dynamicPage.html");
Mike H.
  • 1,731
  • 9
  • 31
1

If you are not a owener of the html file, its better to use iframe to load it. So you will not mess up with their javascript and css files as it loads independently.

In your view

@{
var ExternalPageUrl="www.stackoverflow.com";
}

<div>
<iframe src="@ExternalPageUrl" />
</div>
Murali Murugesan
  • 22,423
  • 17
  • 73
  • 120