asp.net - “bootstrap”不是有效的脚本名称。名称必须以 '.js' 结尾

标签 asp.net twitter-bootstrap scriptmanager

我正在学习 asp.net,因此我正在尝试从 MSDN 构建名为“Wingtip Toys”的项目。

该项目是在 VS 2013 上开发的,我有 VS 2012。当我尝试按照 here 的指令添加 Bootstrap 时我在浏览器中运行时收到错误。

“/”应用程序中的服务器错误。

'bootstrap' is not a valid script name. The name must end in '.js'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: 'bootstrap' is not a valid script name. The name must end in '.js'.

当我在母版页上添加 .js 时,它向我显示另一个错误:

The assembly 'System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not contain a Web resource that has the name 'bootstrap.js'. Make sure that the resource name is spelled correctly.

我还将 CSS 文件添加到 Bundle.config,但结果仍然相同。我已经有可用的 NuGet 包,就像 jQuery.js 错误一样,但我还无法解决这个问题。

最佳答案

这对我有用。 我将其添加到我的 BundleConfig.cs 文件中:

ScriptManager.ScriptResourceMapping.AddDefinition("bootstrap", new ScriptResourceDefinition
    {
        Path = "~/scripts/bootstrap.min.js",
        DebugPath = "~/scripts/bootstrap.js",
        LoadSuccessExpression = "bootstrap"
    });

关于asp.net - “bootstrap”不是有效的脚本名称。名称必须以 '.js' 结尾,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26691086/

相关文章:

asp.net - 使用 moq 模拟 HttpMessageHandler - 如何获取请求的内容?

c# - 是否可以在 Global.asax 中添加对服务层的静态引用?

html - 带有搜索栏的中心 Logo 向右 Bootstrap

javascript - 仅对当前行显示保存按钮

asp.net - ScriptManager 的 EnablePartialRendering 属性到底有什么意义

asp.net - 在 asp.net 页面中包含脚本的正确方法

asp.net - 在 Global.asax 中使用 Trace

asp.net - 在 web.config 中添加程序集引用

html - Bootstrap 缩略图上的填充

javascript - Masterpage.PageLoad() 中的 RegisterStartupScript 将不会在 ContentPlaceHolder 中的异步回发上运行