包括〜/内容静态的html文件到ASP.NET MVC视图 [英] Including static html file from ~/Content into ASP.NET MVC view

查看:98
本文介绍了包括〜/内容静态的html文件到ASP.NET MVC视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我的项目,其中包含有关网站的版权和它的一些联系信息的一些信息得到了母版页。我希望把它拿出来的母版页,并把它放在一个静态文件(出于某种原因,这些文件必须放在〜/内容文件夹)。有没有一种方法,我可以在我看来,像

I've got master page in my project, which contains some information about site copyright and some contact info in it. I'd like to take it out of master page and place it in a static files (for some reason, these files must be placed in ~/Content folder). Is there a way that I can tell in my view something like

<% Html.Include("~/Content/snippet.html") %>   // not a real code

推荐答案

您最好使用一个局部视图(即使它仅包含静态文本),并包括其与 Html.Partial 帮手。但是,如果你坚持:

You are better off using a partial view (even if it only contains static text) and include it with the Html.Partial helper. But if you insist:

<%= File.ReadAllText(Server.MapPath("~/Content/snippet.html")) %>

这篇关于包括〜/内容静态的html文件到ASP.NET MVC视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆