12

I can't get script files to load on my website. Everything else works fine. I haven't tried ScriptResource.axd however.

I have verified this issue exists on both cassini and IIS7.

I have verified my 64bit 4.0 web.config contains the mapping for WebResource.axd.

My system time is correct (I heard there may be issues with that).

I have verified that it works in other projects, so the culprit has to be my web application.

My web application is 4.0 MVC3 web application.

My web.config can be found here.

This error is killing me! Any help would be appreciated!

Resource not found

onof
  • 17,167
  • 7
  • 49
  • 85
Paul Knopf
  • 9,568
  • 23
  • 77
  • 142

9 Answers9

6

Your web.config file is amazing (it's not a compliment): in .NET Framework 4.0, it should be much shorter/lighter.
I think that your handler is declared in the wrong section :

<system.webServer>
    <handlers>
        <add name="WebResource" path="WebResource.axd" verb="GET" type="System.Web.Handlers.AssemblyResourceLoader" />
    </handlers>
</system.webServer>

Normally, the WebResource.axd handler is declared in "system.web" section :

<system.web>
    <httpHandlers>
        <add path="WebResource.axd" verb="GET" type="System.Web.Handlers.AssemblyResourceLoader" validate="True" />
    </httpHandlers>
</system.web>
CedX
  • 3,854
  • 2
  • 36
  • 45
  • I had them in both places at once with no avail. I shouldn't even need them though, seeings how they are already in my machine.config (web.config). – Paul Knopf Dec 19 '11 at 12:55
  • 2
    You're right: this statement is normally not needed. Since you're using MVC, have you check that a routing is not conflicting with WebResource.axd path? I don't use MVC but I know that routing can sometimes be very tricky and lead to unexpected behavior. – CedX Dec 19 '11 at 14:02
  • It has the Ignore .axd entry. – Paul Knopf Dec 20 '11 at 14:10
5

I resolved a similar issue by adding read permissions for Everyone to the folder where the assembly containing the embedded resource was located. Clearly Everyone is overkill, but that might help others researching similar issues.

In our case some resources loaded (so I know the AssemblyResourceLoader was working) and it worked on one machine but not another.

This answer to another question helped me determine what assemblies were not working.

Community
  • 1
  • 1
codyzu
  • 541
  • 3
  • 18
4

I solved this issue on a production machine running again aspnet_regiis:

%WINDIR%\Microsoft .NET\Framework\4.xxxx\aspnet_regiis -i

Probably the standard installation of the framework 4 went wrong.

onof
  • 17,167
  • 7
  • 49
  • 85
4

Bit late but might help someone in the future...

I found that this can happen if the DLL of the web application you are delivering are newer than the current date time. For example, you put your web application on the production server where the server time is older than on your development machine.

Getting the server time in sync with the dev machine did the trick for me...

Srini
  • 446
  • 5
  • 11
  • The date stamped on the DLL also seems to be unaware of time zone. This is a problem if your CI environment is configured as UTC and the server it is deployed to is in a time zone in the western hemisphere. To resolve, the CI server can be set to the same time zone as the target server using [Set-TimeZone](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/set-timezone?view=powershell-7). – NightOwl888 Oct 27 '20 at 16:39
4

Absolutely solution is : https://web.archive.org/web/20211020131200/https://www.4guysfromrolla.com/articles/080906-1.aspx when you check the .net framework code : https://github.com/Microsoft/referencesource/blob/master/System.Web/Handlers/AssemblyResourceLoader.cs you can see the trick : at line 606

WebResourceAttribute wra = FindWebResourceAttribute(assembly, resourceName);

if the assembly does not have WebResourceAttribute it throws 404 error. You can see at this line

if (resourceStream == null) {
            if (resourceIdentifierPresent) {
                LogWebResourceFailure(decryptedData, exception);
            }
            throw new HttpException(404, SR.GetString(SR.AssemblyResourceLoader_InvalidRequest));
        }

so add the WebResourceAttribute to your AssemblyInfo.cs file like this :

[assembly: WebResource("FullNameSpace.SampleResourceFile.js", "text/javascript")]
Paratoner
  • 180
  • 1
  • 5
2

None of the previous solutions worked out for me. Although it took me some time, in the end it was as simple as this:

enter image description here

Luis Gouveia
  • 8,334
  • 9
  • 46
  • 68
1

I had this .axd issue with Umbraco on a production server, it drove me crazy until I found out that the server had different security and under Request Filtering, the extensions .axd and .asmx were not listed in the Allowed filenames by default, and the hosting company had the setting Allow unlisted file name extensions turned off, which was different to my development machine.

Colin Asquith
  • 653
  • 1
  • 6
  • 13
1

Plesk Admins, Please disable the Web Application Firewall to solve this issue.

Tools & Settings > Web Application Firewall > Turn Off

Cheers!

0

Colin's tip got me looking at my new webhost (InterServer). Turns out their Web Application Firewall was the culprit. Switch it to Detect Only or Off, and it's fine.

Gulltop
  • 1
  • 3