ASP.Net捆绑导致HTTPS错误 [英] ASP.Net bundling causing HTTPS error
问题描述
当web.config中的调试标志设置为true时,为什么会出现以下错误?
Why am I getting the following error when the debug flag in the web.config is set to true?
混合内容:" https://example.com/"上的页面已加载 HTTPS,但请求了不安全的脚本 ' http://example.com/scripts/base/?v=JeAlpXPCXHZg9VYU4U-X6 '.
Mixed Content: The page at 'https://example.com/' was loaded over HTTPS, but requested an insecure script 'http://example.com/scripts/base/?v=JeAlpXPCZh9gYv4U-X7_HSaAX3Fj3sGBjwukxEaloQU1'.
捆绑包
bundles.Add(new ScriptBundle("~/scripts/base").Include(
"~/Scripts/Base/app.module.js",
"~/Scripts/Home/home.controller.js",
"~/Scripts/Home/about.controller.js",
"~/Scripts/App/Common/dictionary.class.js",
"~/Scripts/App/Common/constants.class.js",
"~/Scripts/App/Common/multiselect.directive.js",
"~/Scripts/App/Common/paginationOptions.class.js",
"~/Scripts/App/Common/gridHeight.directive.js",
"~/Scripts/App/Common/utility.service.js",
"~/Scripts/App/Common/dateToString.directive.js",
"~/Scripts/App/Common/base.controller.js",
"~/Scripts/App/Common/messagePopover.controller.js"
));
生成的HTML
<script src="/scripts/base?v=JeAlpXPCZh9gYv4U-X7_HSaAX3Fj3sGBjwukxEaloQU1"></script>
推荐答案
今天早上我遇到了类似的问题.我发现我设置的虚拟路径与包含脚本的文件夹结构相同,一旦我重命名了虚拟文件夹路径,便可以通过https请求脚本包.
I had a similar issue this morning. I found that the virtual path I had set was the same as the folder structure containing the scripts, once I had renamed the virtual folder path, the script bundle was then being requested over https.
尝试将脚本包虚拟路径更改为;
Try changing the script bundle virtual path to;
bundles.Add(new ScriptBundle("~/scripts/applicationBase").Include(
"~/Scripts/Base/app.module.js",
....,
....
));
希望有帮助
这篇关于ASP.Net捆绑导致HTTPS错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!