WebResource.axd not found

一曲冷凌霜 提交于 2019-12-04 01:44:26

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

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.

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.

Absolutely solution is : http://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")]

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

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!