CodeKicks.com
Focus on Microsoft Technologies - Tutorials, Articles, Code Samples.

Saturday, September 02, 2006

Accessing Embedded Resources through a URL using WebResource.axd

Many of the built-in ASP.NET server controls require additional, external resources in order to function properly. For example, when using any of the ASP.NET validation controls, the controls rely on a bevy of JavaScript functions to perform their client-side validation. While each validation control could emit such script directly into the page's content, a more efficient approach would be to package these JavaScript functions into an external JavaScript file and then include that file in the page using <script src="PathToExternalJavaScriptFile" type="text/javascript" >. This would reduce the total page size and would allow the browser to cache the external JavaScript file (rather than having to send the JavaScript code down to the browser on each and every page visit/postback).

Prior to ASP.NET 2.0, such external resources that needed to be accessible to the visitor's browser had to be implemented as actual files on the file system. If you've worked with ASP.NET 1.x's validation controls, your pages have included a reference to a JavaScript file /aspnet_client/system_web/version/WebUIValidation.js and there is an actual file with that name residing in the web application's root. Such external resources hamper deployment - if you deploy your application from the testing server to production, it's imperative that the production server have the same external resources (WebUIValidation.js, in this case), in the same locations in the file system. Continue…

Post a Comment