Every now and then I see people asking one of the following questions:
I will try to answer them in a series of blog posts. I will also give some details what web resources are, how they work and what are they good for.
Web Resources are files which are embedded in an assembly. The WebResource.axd HTTP handler loads them and serves them to the browser. Web Resources were introduced in ASP.NET 2.0. If you are using client-side validators, cross page postback or ASP.NET Ajax you are already working with Web Resources.
Consider the following simple page:
You will see this in the rendered page output:
The highlighted part of the URL will be different for different Web Resources. It contains some encoded arguments used to uniquely identify the Web Resource so the WebResource.axd HTTP handler can locate it and serve it. That unique identifier is made up of the embedded resource name (e.g. “WebUIValidation.js”) and the assembly name (e.g. “System.Web.dll”). The “t=633333579827766977” part is basically a timestamp and is used to avoid versioning conflicts. For example if a web site starts using a different version of the assembly the Web Resource URL will change. More info can be found in Nikhil Kothari’s blog post about Web Resources. This blog post describes how to find out what web resources are currently registered in an ASP.NET web page.
The WebResource.axd HTTP handler is registered in machine.config. Hence Web Resources are available in every ASP.NET web site. ASP.NET Ajax introduces a new Web Resource HTTP handler -ScriptResource.axd. It behaves in the same way as WebResource.axd – it loads embedded resources based on the URL and serves them back to the browser. There is one important difference though – ScriptResource.axd compresses the embedded resources using the GZIP protocol so the client browser downloads less bytes.
RadControls for ASP.NET “Classic” utilize the ScriptResource.axd handler provided there is a ScriptManager control on the page. Being native ASP.NET Ajax controls, RadControls “Prometheus” always use the ScriptResource.axd handler.
Stay tuned for more Web Resource related blog posts.
Iana Tsolova is Product Manager at Telerik’s DevTools division. She joined the company back in the beginning of 2008 as a Support Officer and has since occupied various positions at Telerik, including Senior Support Officer, Team Lead at one of the ASP.NET AJAX teams and Technical Support Director. Iana’s main interests are web development, reading articles related to geography, wild nature and latest renewable energy technologies.
Subscribe to be the first to get our expert-written articles and tutorials for developers!