Paul Knopf
Paul Knopf

Reputation: 9776

WebResource.axd not found

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

Upvotes: 13

Views: 33951

Answers (9)

Dirty_Programmer
Dirty_Programmer

Reputation: 107

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

Tools & Settings > Web Application Firewall > Turn Off

Cheers!

Upvotes: 1

Luis Gouveia
Luis Gouveia

Reputation: 8925

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

Upvotes: 3

Gulltop
Gulltop

Reputation: 1

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.

Upvotes: 0

Paratoner
Paratoner

Reputation: 180

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")]

Upvotes: 4

Colin Asquith
Colin Asquith

Reputation: 654

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.

Upvotes: 1

Srini
Srini

Reputation: 456

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...

Upvotes: 4

onof
onof

Reputation: 17367

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.

Upvotes: 4

codyzu
codyzu

Reputation: 551

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.

Upvotes: 5

CedX
CedX

Reputation: 3977

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>

Upvotes: 6

Related Questions