ASP.Net MVC JS / CSS does not work when deployed

I deployed a small web application written in ASP.Net MVC 4. We have the JS / CSS settings configured correctly and they work fine locally. The problem is that when I deploy IIS 6, the packages do not work. Js / css does not load, and when I try to go to the js link in a script, I get 404.

Has anyone deployed MVC 4 for IIS 6 and had this work?

+4
source share
3 answers

The problem was that we were working as a virtual directory configured for ASP.Net 4.0 on the default website, which was configured for ASP.Net 2.0.

We created a new website and installed it in asp.net 4.0, and everything worked perfectly. According to this post in Haacked, URLs without an extension should only work on most IIS 6 instances.

+3
source

Bundles are served through unlimited URLs, for example:

IIS 6 does not support external links without an extension. When it comes across a URL ending in /js or /css , it has no idea that it should bind this url with the aspnet_isapi.dll handler (ASP.NET).

You can read Phil Haack 's blog post explaining how you can configure IIS 6 for ASP.NET MVC to include unlimited URLs. This is about ASP.NET MVC 3, but the same is true for ASP.NET MVC 4.

Oh, and you might consider upgrading to IIS 7.0+, which has this feature by default when operating in integrated pipeline mode.

+2
source

The problem with the mines was in the BundleConfig.cs file in App_Start. My BindleConfig.cs file looked earlier, as shown below.

  bundles.Add(new ScriptBundle("~/Scripts/ui-js").Include( "~/Scripts/ui-js/jquery.min.1.11.1.js" , "~/Scripts/ui-js/bootstrap.min.js" , "~/Scripts/ui-js/bootstrap-slider.js" , "~/Scripts/ui-js/bootstrap-lightbox.js" , "~/Scripts/ui-js/common-script.js" , "~/Scripts/ui-js/html5.js" , "~/Scripts/ui-js/jquery.colorbox.js" , "~/Scripts/ui-js/respond.src.js" , "~/Scripts/ui-js/angular.min.js" , "~/Scripts/ui-js/bootstrap.js" ,"~/Scripts/ui-js/jRate.min.js" , "~/Scripts/ui-js/jcrop.min.js" )); 

And my layout page

 @Scripts.Render("~/Scripts/ui-js") 

After googling, I found a solution, since you cannot use the same folder structure for the new scriptBundle () virtual path.

So, I changed it to

 bundles.Add(new ScriptBundle("~/Scripts/ppScript").Include( "~/Scripts/ui-js/jquery.min.1.11.1.js" , "~/Scripts/ui-js/bootstrap.min.js" , "~/Scripts/ui-js/bootstrap-slider.js" , "~/Scripts/ui-js/bootstrap-lightbox.js" , "~/Scripts/ui-js/common-script.js" , "~/Scripts/ui-js/html5.js" , "~/Scripts/ui-js/jquery.colorbox.js" , "~/Scripts/ui-js/respond.src.js" , "~/Scripts/ui-js/angular.min.js" , "~/Scripts/ui-js/bootstrap.js" ,"~/Scripts/ui-js/jRate.min.js" , "~/Scripts/ui-js/jcrop.min.js" )); 

And on my layout page I called it

 @Scripts.Render("~/Scripts/uiScript") 

NOTE. . You need to do the same with your CSS package and modernizr :)

0
source

Source: https://habr.com/ru/post/1399834/


All Articles