My problem is that after I have uploaded my website to an online server, the html pages display completely fine except for the images, CSS and JavaScript. I know exactly why this is happening and it is related to Ogglas answer in this stackoverflow question: CSS, Images, JS not loading in IIS
Baisically, I can see that in Google debugger this displays:
<link href="/Content/css?v=oJetwWdJWV96VzkmdyDS6ZG-GSKbNSyRhMkB7__C1dQ1" rel="stylesheet">
<script src="/bundles/modernizr?v=wBEWDufH_8Md-Pbioxomt90vm6tJN2Pyy9u9zHtWsPo1"></script>
However there should be a ~
before /Content
and /bundles
so the link should be
<link href="~/Content/css?v=oJetwWdJWV96VzkmdyDS6ZG-GSKbNSyRhMkB7__C1dQ1" rel="stylesheet">
and
<script src="~/bundles/modernizr?v=wBEWDufH_8Md-Pbioxomt90vm6tJN2Pyy9u9zHtWsPo1"></script>
As the ~
symbol indicates the Root directory of the application.
Problem is that I do not know how to correct this problem in my ASP.NET MVC 5 application.
My bundleConfig.cs file already looks like this:
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.validate*"));
// Use the development version of Modernizr to develop with and learn from. Then, when you're
// ready for production, use the build tool at https://modernizr.com to pick only the tests you need.
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
"~/Scripts/modernizr-*"));
bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
"~/Scripts/bootstrap.js",
"~/Scripts/toastr.js",
"~/Scripts/respond.js"));
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css",
"~/Content/toastr.css",
"~/Content/site.css"));
}
}
So I don't understand where I am supposed to make this modification so that after deploying my website, my style links include the ~
symbol .