ASP.Net捆绑导致HTTPS错误

时间:2017-07-06 19:47:09

标签: asp.net https bundling-and-minification

当web.config中的debug标志设置为true时,为什么会出现以下错误?

  

混合内容:加载了“https://example.com/”页面   HTTPS,但请求一个不安全的脚本   '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>

1 个答案:

答案 0 :(得分:1)

今天早上我有类似的问题。我发现我设置的虚拟路径与包含脚本的文件夹结构相同,一旦我重命名了虚拟文件夹路径,就会通过https请求脚本包。

尝试将脚本包虚拟路径更改为;

bundles.Add(new ScriptBundle("~/scripts/applicationBase").Include(
"~/Scripts/Base/app.module.js",
....,
....
));

希望有所帮助