Sunday, 15 June 2014

ASP.NET MVC - weird style being generated in release mode -



ASP.NET MVC - weird style being generated in release mode -

i have this:

bundles.add(new stylebundle("~/content/styles/default").include("~/content/styles/default/site.css"));

on sites have this:

@section styles { @styles.render("~/content/styles/default")) }

my _layout.cshtml looks this:

@rendersection("styles", true)

everything looks good, eh? well, not really. when compiled application in release mode, decided publish it, renders:

<link href="/content/styles/default?v=78dknysp_xsiuzsgxcx_ggnnhzys-b8nndnxqcl47xi1" rel="stylesheet">

instead of generating href file, generates kind of id? guid? why? o.o

this how bundles work. it's main purpose combine multiple css (and js files matter) files 1 package. e.g. no longer have set css (and js) 1 huge file. split sections, add together bundles, , packages 1 item. less web requests, faster page load time.

e.g. lets had 2 css files. one's main, had 1 menu system.

bundles.add(new stylebundle("~/content/styles/default").include( "~/content/styles/default/site.css", "~/content/styles/default/menu.css"));

this show single phone call guid type code (to prevent caching on file changes) on url. url link minified , bundled css.

but browser cannot read that! there no physical path file!

it's sort of virtual file. mvc's bundling uses routing engine point combined , minified version of particle bundle.

asp.net asp.net-mvc

No comments:

Post a Comment