ASP.NET: WebResource.axd call 404 error: how to know which assembly/resource is missing or responsible? ASP.NET: WebResource.axd call 404 error: how to know which assembly/resource is missing or responsible? asp.net asp.net

ASP.NET: WebResource.axd call 404 error: how to know which assembly/resource is missing or responsible?


One of the reasons for this issue is that the registered embedded resource path is incorrect or the resource is not there. Make sure the resource file is added as a Embedded Resource.

Asp.net uses the WebResourceAttribute which you must give the path to the resource.

The resource file needs to be added as a Embedded Resource to the project and the path to it would be the full namespace plus the file name.

So you have the following project resource "my.js" in the project "MyAssembly" the resource path would be "MyAssembly.my.js".

To check what file the web resource handler is not finding you can decrypt the hash code provided on the WebResource.axd url. Please see the example below an how to do that.

using System;using System.Collections.Generic;using System.Linq;using System.Reflection;using System.Web;namespace WebApplication1{    public partial class WebForm1 : System.Web.UI.Page    {        protected void Page_Load(object sender, EventArgs e)        {            byte[] encryptedData = HttpServerUtility.UrlTokenDecode("encoded hash value");            Type machineKeySection = typeof(System.Web.Configuration.MachineKeySection);            Type[] paramTypes = new Type[] { typeof(bool), typeof(byte[]), typeof(byte[]), typeof(int), typeof(int) };            MethodInfo encryptOrDecryptData = machineKeySection.GetMethod("EncryptOrDecryptData", BindingFlags.Static | BindingFlags.NonPublic, null, paramTypes, null);            try            {                byte[] decryptedData = (byte[])encryptOrDecryptData.Invoke(null, new object[] { false, encryptedData, null, 0, encryptedData.Length });                string decrypted = System.Text.Encoding.UTF8.GetString(decryptedData);                decryptedLabel.Text = decrypted;            }            catch (TargetInvocationException)            {                decryptedLabel.Text = "Error decrypting data. Are you running your page on the same server and inside the same application as the web resource URL that was generated?";            }         }    }}

Original code example by Telerik UI for ASP.NET AJAX Team Link: http://blogs.telerik.com/aspnet-ajax/posts/07-03-27/debugging-asp-net-2-0-web-resources-decrypting-the-url-and-getting-the-resource-name.aspx

This should return the URL path that aspt.net believes the embedded resource is at.


I just spent hours on a similar issue. Due to the great article pointed out by Diadistis I was able to decrypt the WebResource url and find out that my WebResource was translated into a wrong assembly pointer, recognizable by the garbage in front of your resource name. After many struggles I found out that this was because I was using the Page.ClientScript.GetWebResourceUrl in a class deriving from another class which resided outside of the assembly my resource was in. Confusing thing was that my class WAS in the same assembly, though the class deriving from was NOT. The this.GetType() parameter many articles state is a must, turned out not to be so much of a must at all in my situation. Actually, it needed to be replaced with a typeof() and it worked! Hope this may prevent others from getting the same headache as I got from this bugger.


In my case, the source of the 404 error was that the date and time of the machine running IIS were wrong (from the past).