Migrating ASP.NET MVC 5 bundling "versions" to MVC 6
Asked Answered
L

1

6

The bundling feature is excluded from MVC 6 and the suggested method is to do bundling using gulp tasks.

Using bundling we used to get a random string at the end of the included css/javascript file url(s). This string was very important because once you changed anything in your css/javascript then a new string would be generated which would force browsers to load the new version(s) of the file(s).

So if you had 3 css files they would be bundled into one and they would look like this:

<link href="/Style/css?v=sGJNctjkEuiEEdR68fh0dDt7bwrHIbu_EfQtgon7oYc1" rel="stylesheet">

How can we achieve the same functionality in MVC 6? I don't know whether gulp can help here or not but I am already using gulp to do minification and bundling.

Lohrman answered 22/8, 2015 at 11:0 Comment(0)
B
7

For beta6 set asp-file-version="true" to retain cache-busting behavior:

<link rel="stylesheet" href="~/css/site.min.css" asp-file-version="true" />

For beta7, use asp-append-version="true".

Butt answered 22/8, 2015 at 13:12 Comment(1)
thank you for your answer. Apparently as of beta 7, you need to use "asp-append-version" as per this link github.com/aspnet/Tooling/issues/149 can you please amend your answer so I can mark it as answer.Lohrman

© 2022 - 2024 — McMap. All rights reserved.