Migrating ASP.NET MVC 5 bundling “versions” to MVC 6

。_饼干妹妹 提交于 2019-12-23 09:31:59

问题


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.


回答1:


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".



来源:https://stackoverflow.com/questions/32155362/migrating-asp-net-mvc-5-bundling-versions-to-mvc-6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!