How does MVC4 use virtual path binding?

In Microsoft MVC4, I see something called bundling to minimize and cache static resources such as CSS and JavaScript . In the ScriptBundle method ScriptBundle I see the first parameter, which is called virtual path , and it should only be relative.

 bundles.Add(new ScriptBundle("~/bundles/jquery").Include("~/Scripts/jquery-1.*")); 

For example, ~/bundles/jquery in the above code.

I have one question, how bundling use this virtual path ? Is it used for something like file caching?

+8
c # asp.net-mvc-4 bundling-and-minification
source share
2 answers

Javascript and CSS Minifying / Bundling

Now, as JS / CSS minimization works, it will dynamically check all your files, read them, minimize them, and then cache the result later. This allows us to modify our files and all files are overridden. When one of our JS / CSS files changes again, this process will restart before the cache expires or the file changes.

Also look at this ScriptBundle and StyleBundle Names post and include the link in this post for more details.

+2
source share

"The new ScriptBundle object has a virtual path that can be anything, anything. It effectively acts as a name by which a node can be identified. It does not have to match the existing path in the folder structure of the website."

Taken from http://www.mikesdotnetting.com/article/197/optimising-asp-net-web-pages-sites-bundling-and-minification

@Richard if you are still looking for an answer.

+7
source share

All Articles