当 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/