ASP.NET 2.0 Web Resources and SharePoint
One of the many new features in ASP.NET 2.0 is called Web Resources. Basically this allows you to store resources like images, scripts and so on, in an assembly. You can do this by using the WebResource attribute. This attribute can be applied on assembly level like this
[assembly: WebResource("image1.jpg", "image/jpeg")]
[assembly: WebResource("help.htm", "text/html", PerformSubstitution=true)]
If you want to use any of your resources in an ASP.NET form (or user control):
<img alt="help image" src=<% = WebResource("image1.jpg") %> />
When the page is rendered the image will point to something like
<img alt="help image" src=WebResource.axd?d=bWzAGpnwEO_jX-h7siKzTsDydsnTE8qDad/>
Many of the default ASP.NET 2.0 controls use this feature to store scripts and images, a good example is the TreeView control. If you want to use the same technique in SharePoint, for example when you want to run ASP.NET 2.0 user controls using the Son of SmartPart, you will face an issue. The problem is that the ISAPI filter of SharePoint will try to process the request to WebResource.axd, so you won’t be able to retrieve any resources. So as Hans suggested, I’m going to explain how to fix this.
To prevent that the ISAPI filter will try to process the requests to WebResource.axd, you have to exclude it as a managed path. On your SharePoint server, open up the SharePoint Central Administration site from the Administrative Tools start menu group and click the “Configure virtual server settings” link. On the next page you will see a list of all your virtual servers, click on the one that you would like to configure (you have to repeat the steps for each virtual server). Next, click the “Define managed paths” link. In the “Add a New Path” section, fill out WebResource.axd as the name of the path, for the type select “Exclude path”. Finally click the OK button. Now you can use WebResource in SharePoint sites!