Homer
Homer

Reputation: 7806

ASP.Net bundling causing HTTPS error

Why am I getting the following error when the debug flag in the web.config is set to true?

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'.

Bundle

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"
));

Generated HTML

<script src="/scripts/base?v=JeAlpXPCZh9gYv4U-X7_HSaAX3Fj3sGBjwukxEaloQU1"></script>

Upvotes: 3

Views: 928

Answers (1)

Robb
Robb

Reputation: 86

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",
....,
....
));

Hope that helps

Upvotes: 3

Related Questions