BundleConfig.cs
public class BundleConfig
{
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new StyleBundle("~/resources/css").Include("~/resources/css/reset.css",
"~/resources/css/style.css", "~/resources/css/invalid.css"));
bundles.Add(new ScriptBundle("~/resources/scripts").Include("~/resources/scripts/jquery-1.3.2.min.js",
"~/resources/scripts/simpla.jquery.configuration.js", "~/resources/scripts/facebox.js",
"~/resources/scripts/jquery.wysiwyg.js"));
}
}
Layout.cshtml
@Styles.Render("~/resources/css")
@Scripts.Render("~/resources/scripts")
它在html中呈现的内容
<link href="/resources/css" rel="stylesheet"/>
<script src="/resources/scripts"></script>
不包括html中的css和js文件路径
答案 0 :(得分:1)
在应用程序启动时添加global.asax文件
BundleConfig.RegisterBundles(BundleTable.Bundles);