ASP MVC - Binding that creates a directory path instead of a file path

I have it:

bundles.Add(new StyleBundle("~/Content/Styles/Default").Include("~/Content/Styles/Default/Site.css")); 

And he creates this:

 <link href="/Content/Styles/Default?v=HG5hShy6_NaqI7SUDWQuc6zijexRxZooKF4ayIgK5tY1" rel="stylesheet"> 

Now I have turned on directory browsing on my web server, and when I click on this style path, it moves me to a directory, not a file! Why?

Update: I still have not been able to resolve this issue, all that I get when I go to the link http://myserver/Content/Styles/Default?v=HG5hShy6_NaqI7SUDWQuc6zijexRxZooKF4ayIgK5tY1 - this is a list of files (for example, on ftp)

+4
source share
2 answers

First, consider the article

Linking is a new feature in ASP.NET 4.5 that makes it easy to merge or merge multiple files into a single file. You can create CSS, JavaScript, and other packages. Fewer files means fewer HTTP requests and this can improve front page load performance.

Request

http://localhost/MvcBM_time/bundles/AllMyScripts?v=r0sLDicvP58AIXN_mc3QdyVvVj5euZNzdsa2N1PKvb81

It is intended for the AllMyScripts package and contains a couple of query lines v = r0sLDicvP58AIXN_mc3QdyVvVj5euZNzdsa2N1PKvb81.

The query string v has a value token, which is a unique identifier used for caching. As long as the package does not change, the ASP.NET application will request AllMyScripts with this token. If any file in the bundle changes, the ASP.NET optimization framework will create a new token, ensuring that the browser requests bundle bundle

Here's how to add a directory with files

 bundles.Add(new StyleBundle("~/jQueryUI/themes/baseAll") .IncludeDirectory("~/Content/themes/base", "*.css")); 

Here's how to add multiple files:

 bundles.Add(new StyleBundle("~/Content/themes/base/css").Include( "~/Content/themes/base/jquery.ui.core.css", "~/Content/themes/base/jquery.ui.resizable.css", "~/Content/themes/base/jquery.ui.selectable.css", "~/Content/themes/base/jquery.ui.accordion.css", "~/Content/themes/base/jquery.ui.autocomplete.css", "~/Content/themes/base/jquery.ui.button.css", "~/Content/themes/base/jquery.ui.dialog.css", "~/Content/themes/base/jquery.ui.slider.css", "~/Content/themes/base/jquery.ui.tabs.css", "~/Content/themes/base/jquery.ui.datepicker.css", "~/Content/themes/base/jquery.ui.progressbar.css", "~/Content/themes/base/jquery.ui.theme.css")); 
+8
source

This is an old question, but Google pointed me here when I was looking for a solution, so I thought that I would add what worked for me.

I had the same problem as yours, and I came across this other question, which, in my opinion, is the same:

MVC4 - Merge does not work if optimizations are set to true

I assume the problem is that you are putting the package in a virtual URL that actually exists but is a directory.

Changing the bundle path fixes the problem I am having.

+3
source

All Articles