I am trying to move an image and a stylesheet from a user control into inline assembly resources. I used Reflector to see that the image and the .css file are embedded in the assembly, but when I try to access them using the URL generated by ClientScript.GetWebResourceUrl (), the resource was not found. I'm at a dead end.
The default namespace for the assembly is:
TestWebApp
File Paths (marked as BuildAction: Embedded Resource)
TestWebApp/Resources/CSS/PaymentHistory.css TestWebApp/Resources/Images/loading.gif
So, my resources are registered as:
[assembly: WebResource("TestWebApp.Resources.CSS.PaymentHistory.css", "text/css", PerformSubstitution = true)] [assembly: WebResource("TestWebApp.Resources.Images.loading.gif", "image/gif")]
A user control (in the same assembly) that accesses resources:
TestWebApp.UserControls.PaymentHistory
To simplify, I'm just trying to reference an image, not a stylesheet, right now. In my Page_Load user control, I set the ImageUrl of the Image control to the resource URL:
image1.ImageUrl = Page.ClientScript.GetWebResourceUrl(this.GetType(), "TestWebApp.Resources.Images.loading.gif");
At runtime, everything seems to work without errors, but it creates a damaged image. Here is the rendering of the image source:
<img style="border-width:0px;" src="/WebResource.axd?d=8fC_1tLPjrUCxmFc_Q2MKY0-pHAak-sTWkpLLV3D56H_c08LujXC63ia2PNICE65_i-Q4JqprAigLpbrXG-rIAr6ePO4HHcdQKgdd3szlThv2gizxOJLJsPRNe-b_M6ApTwPsH_5oZAuONTN0cumOTRr1nA1&t=635133745137507721" id="ph1_image1">
If I go to this URL in my browser, I get 404, the resource was not found. What am I doing wrong?
EDIT: There must be something fundamental, I donβt understand and / or do something really stupid. Here is a simple example of VS 2010 . I followed all the necessary steps that I know to implement JScript1.js and access it through WebResource.axd, but it gets an error.