'jquery' 不是有效的脚本名称。名称必须以“.js”结尾
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14974767/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
'jquery' is not a valid script name. The name must end in '.js'
提问by mstilapia
My ASP.Net project is working well, when suddenly we had a power failure. When I ran my web app, it is now showing a lot of
我的 ASP.Net 项目运行良好,突然断电。当我运行我的网络应用程序时,它现在显示了很多
Could not load assembly Sanitizer..." then "Could not load "HtmlAgility...
无法加载程序集消毒剂...”然后“无法加载”HtmlAgility...
errors. I was able to resolve these previous errors by uninstalling / reinstalling them using Manage Nuget Package Solutionsinside Visual Studio 2012.
错误。我能够通过使用Visual Studio 2012 中的Manage Nuget Package Solutions卸载/重新安装它们来解决这些以前的错误。
But now I encountered another error:
但是现在我遇到了另一个错误:
'jquery' is not a valid script name. The name must end in '.js'."
'jquery' 不是有效的脚本名称。名称必须以 '.js' 结尾。”
I tried to do same thing by re-installing the package but it does not work. What should I do to resolve this? I already have a jquery.js file located on my root\Scripts folder. I also added reference to this file inside my section:
我试图通过重新安装软件包来做同样的事情,但它不起作用。我应该怎么做才能解决这个问题?我的 root\Scripts 文件夹中已经有一个 jquery.js 文件。我还在我的部分中添加了对此文件的引用:
<script src="Scripts/jquery.js"></script>
But still it won't work. Please help.
但它仍然行不通。请帮忙。
回答by mstilapia
By the way guys, I was able to resolve this by installing the AspNet.ScriptManager.jQuery.UI.Combined
and AspNet.ScriptManager.jQuery
packages using the Nuget tool.
顺便说一句,我能够通过使用 Nuget 工具安装AspNet.ScriptManager.jQuery.UI.Combined
和AspNet.ScriptManager.jQuery
包来解决这个问题。
回答by PK-1825
Right click on your project and go to manage NuGet packagesand then just install
右键单击您的项目并转到管理 NuGet 包,然后安装
AspNet.ScriptManager.jQuery.UI.Combined
AspNet.ScriptManager.jQuery.UI.Combined
and
和
AspNet.ScriptManager.jQuery
AspNet.ScriptManager.jQuery
packages
包裹
回答by Vijay Kumbhoje
Here is working solution
这是工作解决方案
Open
Global.asax
in your solution
Global.asax
在您的解决方案中打开
Copy below code just modify your Jquery Version accordingly and paste it inside Application_Start event of Global.asax
复制下面的代码只需相应地修改您的 Jquery 版本并将其粘贴到 Application_Start 事件中 Global.asax
ScriptManager.ScriptResourceMapping.AddDefinition("jquery", new ScriptResourceDefinition
{
Path = "~/Scripts/jquery-1.10.2.min.js",
DebugPath = "~/Scripts/jquery-1.10.2.js",
CdnPath = "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.10.2.min.js",
CdnDebugPath = "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.10.2.js",
CdnSupportsSecureConnection = true,
LoadSuccessExpression = "window.jQuery"
});
ScriptManager.ScriptResourceMapping.AddDefinition("jquery.ui.combined", new ScriptResourceDefinition
{
Path = "~/Scripts/jquery-ui-1.10.2.min.js",
DebugPath = "~/Scripts/jquery-ui-1.10.2.js",
CdnPath = "http://ajax.aspnetcdn.com/ajax/jquery.ui/1.10.2/jquery-ui.min.js",
CdnDebugPath = "http://ajax.aspnetcdn.com/ajax/jquery.ui/1.10.2/jquery-ui.js",
CdnSupportsSecureConnection = true
});
ScriptManager.ScriptResourceMapping.AddDefinition("bootstrap", new ScriptResourceDefinition
{
Path = "~/Scripts/bootstrap.min.js",
DebugPath = "~/Scripts/bootstrap.js",
CdnPath = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js",
CdnDebugPath = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.js",
CdnSupportsSecureConnection = true
});
回答by VK_217
回答by Al Ashcroft
I had a similar situation, but mine happened after I tried to update DotNetOpenAuth.Core. First it said I needed to update NuGet, which I did, then I updated OpenAuth. After that I started getting the "'jquery' is not a valid script name. The name must end in '.js'.".
我有类似的情况,但我的情况发生在我尝试更新 DotNetOpenAuth.Core 之后。首先它说我需要更新 NuGet,我做到了,然后我更新了 OpenAuth。之后,我开始收到“'jquery' 不是有效的脚本名称。名称必须以 '.js' 结尾。”。
If I removed the line adding the jquery bundle, it would happen on jquery-ui etc.
如果我删除了添加 jquery 包的行,它会发生在 jquery-ui 等上。
I uninstalled and reinstalled both the AspNet.ScriptManager.jQuery and AspNet.ScriptManager.Bootstrap packages (as it would eventually complain about that), and still no luck.
我卸载并重新安装了 AspNet.ScriptManager.jQuery 和 AspNet.ScriptManager.Bootstrap 包(因为它最终会抱怨),但仍然没有运气。
Final step I did was to uninstall and reinstall AjaxControlToolkit from the package manager console and that fixed it for me.
我做的最后一步是从包管理器控制台卸载并重新安装 AjaxControlToolkit,并为我修复了它。
回答by bestcoder
Thanks for posting your follow-up answer. I got this same error after installing jQuery.UI to a new ASP.NET web forms project based on the new One ASP.NET template in VS.NET 2013 and adding this line to the script manager in the master page:
感谢您发布您的后续答案。在将 jQuery.UI 安装到基于 VS.NET 2013 中新的 One ASP.NET 模板的新 ASP.NET Web 表单项目并将此行添加到母版页中的脚本管理器后,我遇到了同样的错误:
<asp:ScriptReference Name="jquery.ui.combined" />
After installing the AspNet.ScriptManager.jQuery.UI.Combined NuGet package as you stated, the error was immediately resolved.
按照您的说明安装 AspNet.ScriptManager.jQuery.UI.Combined NuGet 包后,该错误立即得到解决。
回答by xizwyck
I had a similar situation and already had the script reference (above) but I also needed to make sure that the dll was copied to the local folder.
我遇到了类似的情况并且已经有了脚本参考(上面),但我还需要确保将 dll 复制到本地文件夹。
F4 on AspNet.ScriptManager.jQuery and AspNet.ScriptManager.jQuery.UI.Combined and set Copy Local to True.
在 AspNet.ScriptManager.jQuery 和 AspNet.ScriptManager.jQuery.UI.Combined 上按 F4 并将复制本地设置为 True。
回答by clarence_odbody
may be a little late to the party but I had the same problem and tried numerous solutions as per above and on other pages. I would get the error on the last script reference, no matter what that reference was. I finally decided to remove all the script references and use bundles instead. For example, default application has the following in bundles.config:
聚会可能有点晚了,但我遇到了同样的问题,并按照上述和其他页面尝试了多种解决方案。无论该引用是什么,我都会在最后一个脚本引用中得到错误。我最终决定删除所有脚本引用并使用包代替。例如,默认应用程序在 bundles.config 中有以下内容:
bundles.Add(new ScriptBundle("~/bundles/MsAjaxJs").Include(
"~/Scripts/WebForms/MsAjax/MicrosoftAjax.js",
ScriptManager.ScriptResourceMapping.AddDefinition(
"respond",
new ScriptResourceDefinition
{
Path = "~/Scripts/respond.min.js",
DebugPath = "~/Scripts/respond.js",
}
);
So I changed 'respond' to a bundle instead of a script reference:
因此,我将“响应”更改为包而不是脚本引用:
bundles.Add(new ScriptBundle("~/bundles/respond").Include(
"~/Scripts/respond-1.4.2.js"));
along with all other script references, and added them to the master page header:
连同所有其他脚本引用,并将它们添加到母版页标题:
<asp:PlaceHolder runat="server">
<%: Scripts.Render("~/bundles/WebFormsJs") %>
<%: Scripts.Render("~/bundles/MsAjaxJs") %>
<%: Scripts.Render("~/bundles/jquery") %>
<%: Scripts.Render("~/bundles/jqueryui") %>
<%: Scripts.Render("~/bundles/modernizr") %>
<%: Scripts.Render("~/bundles/respond") %>
</asp:PlaceHolder>
This removed the error - finally after 2 days - and allowed me to run some basic pages, including the default Register.aspx page. Not sure what I'll run into next but figured I would pass this along.
这消除了错误 - 终于在 2 天后 - 并允许我运行一些基本页面,包括默认的 Register.aspx 页面。不知道我接下来会遇到什么,但我想我会传递这个。
回答by Terry H
This fixed my issue. Add this BundleConfig.cs Check your paths.
这解决了我的问题。添加这个 BundleConfig.cs 检查你的路径。
ScriptManager.ScriptResourceMapping.AddDefinition("bootstrap", new ScriptResourceDefinition {
Path = "~/scripts/bootstrap.min.js",
DebugPath = "~/scripts/bootstrap.js",
LoadSuccessExpression = "bootstrap"});
And kept this in the ScriptManager on the site.master
并将其保存在 site.master 上的 ScriptManager 中
<asp:ScriptReference Name="bootstrap" />
Follow this articlefor more clarity if needed
如果需要,请关注这篇文章以获得更清晰的信息
回答by nitin
Add this to your Web.config and the issue will be resolved:
将此添加到您的 Web.config,问题将得到解决:
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>