0

Is there a way to modify all the links to js and css files in my webforms aspx pages without making a call to a helper function?

I want to write a url:
FROM ...../Scripts/file.js
TO ...../Scripts/634969723944992444/file.js

I can do this:

<script type="text/javascript" src="<%=Url.Helper(@"Scripts/file.js")%>"></script>

where the helper function will include the last modified time of the file as ticks in the url.

Is there an easy way I can modify the urls on all my pages with out using such helper function?

Thanks

4

2 回答 2

0

老实说,我认为你最好的选择是放弃你的努力,只使用Bundling 和 Minification

除了捆绑(减少 HTTP 请求的数量)和缩小(减少文件大小)之外,它还会自动对您的捆绑包进行版本控制(使用查询字符串),确保浏览器在您的脚本或样式表之一发生更改时始终获得最新版本。

如果您使用的是 ASP.NET 4.5,则您已经可以访问此功能。对于旧版本,您可以通过NuGet安装。

其他有用的链接: 向 Web 表单添加捆绑和缩小

于 2013-03-05T21:56:45.870 回答
0

您可以编写一个 HTTPModule 来执行此操作。您也可以改为在路径中放置时间,只需使用查询字符串来标记更新

file.js?v=1 file.js?v=2 file.js?v=3 等

于 2013-03-05T21:39:27.693 回答