I have been developing the MVC5 web application for several months. I published on each of the 3 servers used for development, testing, and the intended public server. Everything was tested by a team of a dozen beta testers, and this weekend it was decided to go live using a web application.
Before publishing the web application on a live (public) host, I changed the web.config file to disable the debugging mode for the public site. After the publication, there were all kinds of problems associated with the lack of CSS and JS resources.
After reading a large number of articles on 404 links and errors, I found one that hinted to add the following to Web.config:
<modules runAllManagedModulesForAllRequests="true"> <remove name="BundleModule" /> <add name="BundleModule" type="System.Web.Optimization.BundleModule" /> </modules>
This resolved 404 issues for the StyleBundle and ScriptBundle configurations, but now I have 404 errors for images that previously worked fine. I am not sure of the best way to resolve them. I donβt want to move images, and I donβt want to edit CSS, as these are distribution files (jQueryUI, ThemeRoller, DataTables, etc.). I want to leave my distribution directory structure and source files (CSS and JS) unmodified.
An example of a problem.
The DataTables distribution is located in the ~ / Scripts folder:
/Scripts/DataTables-1.10.2/ /Scripts/DataTables-1.10.2/media/css /Scripts/DataTables-1.10.2/media/images /Scripts/DataTables-1.10.2/media/js
Package Configuration:
bundles.Add(new ScriptBundle("~/bundles/DataTables").Include( "~/Scripts/DataTables-1.10.2/media/js/jquery.dataTables.js")); bundles.Add(new StyleBundle("~/bundles/DataTables.css").Include( "~/Scripts/DataTables-1.10.2/media/css/jquery.dataTables.css"));
jquery.dataTables.css contains links to .. /images/someimage.png and with the debugging mode turned on Web.config, this works flawlessly. Now that the debugging mode is off and the Bundles mining / merging, I get 404 errors:
http://example.com/GenericError.htm?aspxerrorpath=/images/someimage.png"
It seems that the image URL is now considered relative to / Bundles / - although I'm not sure.
There should be an additional configuration that I am missing. Can someone point me in the right direction?
EDIT
Rafael comments on this question, and his URL to another similar SO question did not help solve this problem. Sean's BundleTransformer recommendation seems like this might work, but I can't find documentation on how to install this package.