views:

43

answers:

2

I'm experimenting with javascript and css caching in ASP.NET MVC. Is it possible to intercept calls to the server for these types of files?

For example, if a request gets to the server for

~/Scripts/Something.CurrentVersion.js

I would like to intercept this call and tell the server to return

~/Scripts/SomeOtherFile.js

Would it be possible to hook into some event or create a new module or HttpHandler to accomplish this?

A: 

Yep. HttpHandler is certainly one way to go. Beware of the integration to IIS though - to have full control over mapping you have to run it in integrated mode - otherwise IIS itself will process request BEFORE it will get to the worker process

mfeingold
So what would be the recommended way? Do you perhaps have any example to get started with?
Jaco Pretorius
A: 

Checkout these links for different ways:

http://weblogs.asp.net/rashid/archive/2009/04/28/script-and-css-management-in-asp-net-mvc.aspx http://weblogs.asp.net/rashid/archive/2009/05/02/script-and-css-management-in-asp-net-mvc-part-2.aspx http://www.codeproject.com/KB/aspnet/combineMinify.aspx

Bcelik
Thanks - just one last question - if I use the same approach as in the codeproject article, would it still impact deployment into IIS like mfeingold mentioned?
Jaco Pretorius
@www.jacopretorius.net : It is not an HttpHandler. So no it wont.
Bcelik