MVC4捆绑:其中,包中的URL举行 [英] MVC4 Bundling: where the URL for bundle is held
问题描述
当捆在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 return404
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 theScripts.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屋!