0
BundleConfig:Web表单页面上捆绑不注册脚本
Public Class BundleConfig
' For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkID=303951
Public Shared Sub RegisterBundles(ByVal bundles As BundleCollection)
bundles.Add(New ScriptBundle("~/bundles/WebFormsJs").Include(
"~/Scripts/WebForms/WebForms.js",
"~/Scripts/WebForms/WebUIValidation.js",
"~/Scripts/WebForms/MenuStandards.js",
"~/Scripts/WebForms/Focus.js",
"~/Scripts/WebForms/GridView.js",
"~/Scripts/WebForms/DetailsView.js",
"~/Scripts/WebForms/TreeView.js",
"~/Scripts/WebForms/WebParts.js"))
' Order is very important for these files to work, they have explicit dependencies
bundles.Add(New ScriptBundle("~/bundles/MsAjaxJs").Include(
"~/Scripts/WebForms/MsAjax/MicrosoftAjax.js",
"~/Scripts/WebForms/MsAjax/MicrosoftAjaxApplicationServices.js",
"~/Scripts/WebForms/MsAjax/MicrosoftAjaxTimer.js",
"~/Scripts/WebForms/MsAjax/MicrosoftAjaxWebForms.js"))
' Use the Development version of Modernizr to develop with and learn from. Then, when you’re
' ready for production, use the build tool at http://modernizr.com to pick only the tests you need
bundles.Add(New ScriptBundle("~/bundles/modernizr").Include(
"~/Scripts/modernizr-*"))
bundles.Add(New ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.min.js"
))
bundles.Add(New ScriptBundle("~/bundles/bootstrap").Include(
"~/Scripts/bootstrap.min.js"
))
ScriptManager.ScriptResourceMapping.AddDefinition("respond", New ScriptResourceDefinition() With {
.Path = "~/Scripts/respond.min.js",
.DebugPath = "~/Scripts/respond.js"})
End Sub
End Class
应用程序启动:
Sub Application_Start(sender As Object, e As EventArgs)
' Fires when the application is started
RouteConfig.RegisterRoutes(RouteTable.Routes)
BundleConfig.RegisterBundles(BundleTable.Bundles)
BundleTable.EnableOptimizations = True
Dim builder = New ContainerBuilder()
RegisterTypes(builder)
'Setup container with builder
_containerProvider = New ContainerProvider(builder.Build())
End Sub
母版页头:
<head runat="server">
<title></title>
<!-- standard NCCI meta tags -->
<meta name="AUTHOR" content="NCCI" />
<meta http-equiv="CACHE-CONTROL" content="NO-CACHE" />
<meta http-equiv="PRAGMA" content="NO-CACHE" />
<meta name="ROBOTS" content="NONE" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<asp:PlaceHolder runat="server">
<% Styles.Render("~/Content/css") %>
<% Scripts.Render("~/bundles/jquery") %>
<% Scripts.Render("~/bundles/bootstrap") %>
</asp:PlaceHolder>
</head>
我也有安装在我的项目的网络优化。为什么没有在页面上呈现任何脚本/样式?
bundle config中的文件路径引用了正确的文件,所以我不知道它为什么不起作用。
至于样式,似乎你没有在任何地方注册“〜/ Content/css”。而且<%Scripts ....等缺少冒号。它应该读取<%:Scripts.Render –
除非你有在Bundle.Config当然配置的样式:) –
@FrankWitte Riiight,你可以看到我有点新的Web窗体和aspx。我想念我的MVC和剃刀:(如果你把你的评论放入答案中,我会选择它作为答案 – Andrew