It's real easy to retrieve Embedded Resources in ASP.NET 2.0, as it has this functionality built in. However, there is nothing in place to do this in ASP.NET 1.1. It's a problem if you're, like me, maintaining old ASP.NET 1.1 apps that can't be converted to 2.0 (for whatever reason).

Here's the solution I came up with (I think dustyd probably helped). I wanted something that would closely mimic the WebResource.axd of ASP.NET 2.0.

For Starters...

I created an HttpHandler to handle the file request. This is pretty much the meat of the project:

EmbeddedResourceHandler.cs

The Solution Layout...

Create a new project in your solution and put the code above in a new class. Also, in this new project, you'll add your extraneous files. Here's what it should look like:

Be sure to edit the properties on your extraneous files and mark them as "Embedded Resource."

Next, the Web.Config entry...

Now, under the <HttpHandler> tag add in this entry. "CustomControls" is the name name of the project/assembly that contains the EmbeddedResourceHandler class that's listed above.

<add verb="*" path="Fetch.ashx" validate="false"
type="Zinknation.EmbeddedResourceProvider.EmbeddedResourceHandler, CustomControls" />

Presumably, if your project builds now, you should be able to check to see if it it's working by going to: http://yourhost/fetch.ashx

If you don't pass it any parameters, it gives you a Manifest of all the Embedded Resources in the project. You can use the links it provides to get the direct URL for the file you want. For instance, if I wanted to attain JScript1.js in the above example, I would use the link http://<SiteName>/fetch.ashx?a=EmbeddedResources.JScript1.js

That's about it!

If you attempt to use this code and have any questions or problems, feel free to Email me or post a comment; I'll try to help out. Also, feel free to modify the source code as you see fit. There is some stuff in there, such as the caching, that may or may not work well for you.

12/18/2006 11:00:54 AM (Central America Standard Time, UTC-06:00)
Funny that your screenshot is of Visual Studio 2005!
12/18/2006 11:06:45 AM (Central America Standard Time, UTC-06:00)
Hah, you're correct. I took that in VS 2005. The reason being... I don't have VS 2003 installed at home anymore. But, rest assured, the functionality is the same in ASP.NET 1.1 / VS2003.

Cudos to you for catching that; I guess I owe you a coke or something.
Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):