ScriptBundle不渲染处于VirtualDirectory脚本 [英] ScriptBundle not rendering scripts that are in a VirtualDirectory
问题描述
我所在的模块部署虚拟目录内的主.NET Web应用程序之下的模块化asp.net应用程序。我们有很多东西的通用模块。我试图将所有常用的脚本文件出每个客户的具体项目到一个通用模块。
I have a modular asp.net app where the modules are deployed inside virtual directories underneath the primary .net web application. We have a common module with a lot of stuff. I tried to move all of the common script files out of each client specific project into a common module.
如果我创建一个在根级别引用文件的脚本包,它使得脚本代码插入HTML。但它不会渲染脚本标签指向的文件在子虚拟目录捆绑。
If I create a script bundle that references files at the root level, it renders the script tag into the html. But it won't render script tags for bundles that point to files in a sub virtual directory.
例如:
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/App_Modules/Common/Scripts/jquery-1.*"));
不再呈现任何脚本标签,现在我得到的jQuery错误客户端。我看了看结果HTML,现在没有更多的脚本标签下载jQuery库。
no longer renders any script tag and now I get jquery errors client side. I looked at the resultant html, and now there's no more script tag to download the jquery library.
推荐答案
我有同样的问题。根本原因是,我只包含在捆绑minified的脚本。有一次,我放在scripts目录中uncom pressed脚本,它正确呈现它们。
I had the same problem. The root cause was that I included only minified scripts in the bundle. Once I placed in the scripts directory the uncompressed scripts, it rendered them correctly.
这篇关于ScriptBundle不渲染处于VirtualDirectory脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!