[英]Loading HTML Page into Body
為什么這不起作用?
@{
ViewBag.Title = "Website Account Manager";
}
<h2>@ViewBag.Message</h2>
<p>
@{
System.IO.StreamReader myreader = new System.IO.StreamReader("../htdocs/websiteaccounts/Views/Home/index.htm");
myreader.ReadToEnd();
myreader.Close();
}
</p>
我只是希望index.htm文件顯示在我上面的cshtml文件的正文中,但它沒有在正文中顯示。 其他一切都很好,只有那個問題。
請試試這個
string path = AppDomain.CurrentDomain.BaseDirectory;
System.IO.StreamReader myreader = new System.IO.StreamReader(path + "MyTest\\randerhtml.html");
string s = myreader.ReadToEnd();
myreader.Close();
@(new HtmlString(s))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.