问题
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!
回答1:
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>
回答2:
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.
回答3:
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.
回答4:
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")]
回答5:
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...
回答6:
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.
来源:https://stackoverflow.com/questions/8470080/webresource-axd-not-found