ASP.NET pooling - virtual paths by default?

As far as I can tell (because the frank documentation on System.Web.Optimization very sparse), the way to combine in ASP.NET is that you register a set of files (Javascript or CSS, corresponding ScriptBundle and StyleBundle ) and map them to a virtual path ; e.g. ~/bundles/jqueryui for all jQuery UI scripts. Later, ASP.NET can minimize these files when you work in non-debug mode, and the minimized version will be available in the virtual path specified for the package.

Setting the pool by default registers some script packages with ~/bundles/... as a virtual path, and some CSS with ~/Content/css as a virtual path. My question is: does this not contradict? Wouldn't it make sense to have something like ~/bundles/js/... and ~/bundles/css/... ? In fact, the ~/Content directory actually exists as a real directory, so even the probability of a name clash. I would think that you want your virtual path bundles to be directories that do not exist by default and are not intended to be created on a real file system. Is there any reason why ~/Content/css used for virtual CSS package paths that I don't understand?

+6
source share
1 answer

An excellent question, and the story that in general it does not matter at all. However, some script files and CSS depend on their physical location on disk because they use relative paths to link to other content. For example, you look at the default jQuery package in a new ASP.NET 4.5 project, which you see has a pretty long way. This is because jQuery CSS has relative links to some image files. So that those who correctly resolve them have business, or things like ".." will not be returned to the correct parent directory.

+7
source

All Articles