c# - MVC4 捆绑 : where the URL for bundle is held

标签 c# asp.net-mvc asp.net-mvc-4 bundling-and-minification system.web.optimization

当 bundle 在 MVC4 中注册时,什么负责“拦截”对 /bundles/someBundle?v=1hDzBpmYJm4Iu-OjRN1YqS1WeNThVl0kStLJGP8WCr41 的传入 http 请求? 此外,由于每个包的哈希值仅计算一次(在第一次请求时),实际保存的哈希值在哪里 - 如果传入的哈希值不匹配,是否可以返回 404

最佳答案

what is responsible for "intercepting" incoming http requests for ~/bundles/someBundle

~/bundles/someBundle 没有传入请求。它是您正在使用的服务器端助手 (Scripts.Render),它在服务器上(在相同的 HTTP 请求中)解释此值并在生成的 HTML 中吐出正确的 url。

also since hash for each bundle is calculated only once (at a first request), where is that actually held,

实际的包内容存储在服务器端缓存中:HttpContext.Cache。实际散列表示每次使用 Scripts.Render 帮助程序时计算的此内容的 SHA256 散列。


更新:

这是System.Web.Optimization.BundleModule当您引用 System.Web.Optimization 程序集时自动注册,该程序集负责拦截对 /bundles/someBundle?v=1hDzBpmYJm4Iu-OjRN1YqS1WeNThVl0kStLJGP8WCr41 等 url 的请求并返回实际内容。

关于c# - MVC4 捆绑 : where the URL for bundle is held,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19114862/

相关文章:

c# - WPF DataGrid 禁用的单元格正在接收文本输入

javascript - 将 C# 3D 数组移植到 JS 3D 数组

c# - 如何在 ASP.NET MVC 定时器上调用函数

c# - MVC LINQ - 在相关表中使用 Contains 搜索/查询文本

c# - MVC : Where to put business logic?

c# - 在 ASP.NET MVC 4 中将缓存设置为最高级别

c# - 在 C# 中使用命名空间系统声明可以省略吗?

c# - 我应该用数据传输对象包装实体吗

asp.net-mvc - 当旧文件仍然存在于目录中时 MVC Bundle {version}

.net - 可以在 .net 或 mvc4 中基于 signalR 的应用程序中完成 seo