Tuesday, November 23, 2010

Understanding ScriptResource and WebResource in ASP.NET

Understanding ScriptResource and WebResource in ASP.NET

While recording load test script on ASP.Net application, you may come across following files based on your code design. These files need to be parameterized, as the file URL contain time stamp in encrypted format and resource id. You may encounter multiple files in a single page with different URL parameters.

Attaching the files and URL screen shot.

A web resource is a file embedded in an assembly.  This file can either be a JavaScript file or a BMP, or any other emendable type of resource in an assembly. 

There are two basic ways to getting at your assembly resources loaded on your ASP.NET web page.  ScriptResource.axd and WebResource.axd.

The URL for WebResource.axd looks like the following:
The format of this URL is WebResource.axd?d=encrypted identifier&t=time stamp value. The "d" stands for the requested Web Resource. The "t" is the timestamp for the requested assembly, which can help in determining if there have been any changes to the resource.

Some of the advantages of using these files
1. Automatically GZip/Compressing your scripts over HTTP for delivery.
2. Dynamically resolving Release/Debug scripts based on build parameters.  This is useful, if you keep two types of the same script: one for debug, and one packed for release.
3. Can be used for Non-MsAJAX Framework script assets such as jQuery.

Following are the links for better understanding of this post.



  1. Hi Bharath,

    I am running my neoload script on a different URL than the recorded url. While running, it gives errors for WebResource.axd.

    Can you help me in handling this situation?


  2. QTP Admin,

    In .aspx page you have values for "d" and "t", need to Parameterize all those values for all the .adx files.

  3. But WebResource.axd is appearing many times and there are 100+ places when WebResource.axd is appearing in the script. How to parametrize all this manually? It will a very lengthy task.

    Any way to automate it?
    See the sample code - http://paste.pocoo.org/show/403990/

    WebResource.axd is appearing multiple times in the code

  4. QTP Admin,

    In the variable extractor of the NeoLoad, you have the radio button to choose all the occurrences, so all the d and t values are captured for that page (Make sure to give proper left and right boundary). Now replace the values as ${d_1}, ${d_2}....