MVC4捆绑:其中,包中的URL举行 [英] MVC4 Bundling: where the URL for bundle is held

查看:148
本文介绍了MVC4捆绑:其中,包中的URL举行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当捆在MVC4被注册,什么是负责为拦截来袭 HTTP 请求/包/ someBundle?V = 1hDzBpmYJm4Iu- OjRN1YqS1WeNThVl0kStLJGP8WCr41
还因为对于每个束散列计算只一次(在第一请求),其中,是实际持有, - 并且是有可能返回 404 如果传入散列不匹配


解决方案

  

什么是负责拦截来袭HTTP请求的〜/包/ someBundle


有没有进入的请求〜/包/ someBundle 。这是您正在使用服务器端的辅助( Scripts.Render )在服务器上(在同一个HTTP请求内)间$ P $点这个数值吐出正确的URL在生成的HTML。


  

也因为对于每个包散列只计算一次(在第一次请求),其中是实际持有,


实际捆绑内容存储在服务器侧高速缓冲: HttpContext.Cache 。再$ P $的实际哈希psents上计算每次使用 Scripts.Render 助手时该内容的SHA256哈希值。


更新:

这是 系统。 Web.Optimization.BundleModule 即自动注册时,您引用System.Web.Optimization大会,负责拦截网址请求如 /包/ someBundle ?v = 1hDzBpmYJm4Iu-OjRN1YqS1WeNThVl0kStLJGP8WCr41 和返回的实际内容。

When the bundle is registered in MVC4, what is responsible for "intercepting" incoming http requests for /bundles/someBundle?v=1hDzBpmYJm4Iu-OjRN1YqS1WeNThVl0kStLJGP8WCr41? also since hash for each bundle is calculated only once (at a first request), where is that actually held, - and is it possible to return 404 if an incoming hash does not match

解决方案

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

There are no incoming requests to ~/bundles/someBundle. It's the server side helper that you are using (Scripts.Render) that on the server (within the same HTTP requests) interprets this value and spits the correct url in the resulting HTML.

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

The actual bundle contents is stored in the server side cache : HttpContext.Cache. The actual hash represents a SHA256 hash on this content that is calculated every time you use the Scripts.Render helper.


UPDATE:

It's the System.Web.Optimization.BundleModule that is auto-registered when you reference the System.Web.Optimization assembly that is responsible for intercepting requests to urls like /bundles/someBundle?v=1hDzBpmYJm4Iu-OjRN1YqS1WeNThVl0kStLJGP8WCr41 and returning the actual contents.

这篇关于MVC4捆绑:其中,包中的URL举行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆