11

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

4

9 回答 9

5

您的 web.config 文件很棒(这不是恭维):在 .NET Framework 4.0 中,它应该更短/更轻。
我认为您的处理程序在错误的部分中声明:

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

通常,WebResource.axd 处理程序在“system.web”部分中声明:

<system.web>
    <httpHandlers>
        <add path="WebResource.axd" verb="GET" type="System.Web.Handlers.AssemblyResourceLoader" validate="True" />
    </httpHandlers>
</system.web>
于 2011-12-18T07:19:26.737 回答
5

我通过将每个人的读取权限添加到包含嵌入式资源的程序集所在的文件夹来解决了类似的问题。显然,每个人都矫枉过正,但这可能有助于其他研究类似问题的人。

在我们的例子中,加载了一些资源(所以我知道 AssemblyResourceLoader 正在工作)并且它在一台机器上工作,但在另一台机器上却不行。

这个对另一个问题的回答帮助我确定了哪些程序集不起作用。

于 2012-05-31T14:38:54.697 回答
4

有点晚,但将来可能会帮助某人......

我发现如果您交付的 Web 应用程序的 DLL 比当前日期时间更新,就会发生这种情况。例如,您将 Web 应用程序放在服务器时间比开发机器上的生产服务器上。

让服务器时间与开发机器同步对我来说是诀窍......

于 2013-07-19T04:59:04.737 回答
4

我在再次运行aspnet_regiis的生产机器上解决了这个问题:

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

可能框架4的标准安装出错了。

于 2012-08-23T09:54:59.167 回答
4

绝对解决方案是:http ://www.4guysfromrolla.com/articles/080906-1.aspx 当您检查 .net 框架代码时:https ://github.com/Microsoft/referencesource/blob/master/System.Web/ Handlers/AssemblyResourceLoader.cs 你可以看到诀窍:在第 606 行

WebResourceAttribute wra = FindWebResourceAttribute(assembly, resourceName);

如果程序集没有 WebResourceAttribute 它会引发 404 错误。你可以在这一行看到

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

所以将 WebResourceAttribute 添加到您的 AssemblyInfo.cs 文件中,如下所示:

[assembly: WebResource("FullNameSpace.SampleResourceFile.js", "text/javascript")]
于 2016-04-21T07:10:28.373 回答
1

我在生产服务器上遇到了 Umbraco 的这个 .axd 问题,它让我发疯,直到我发现服务器具有不同的安全性并且在请求过滤下,扩展名 .axd 和 .asmx默认情况下未列在允许的文件名中,并且托管公司关闭了允许未列出的文件扩展名的设置,这与我的开发机器不同。

于 2015-04-16T10:10:40.360 回答
1

以前的解决方案都不适合我。虽然花了我一些时间,但最后还是这么简单:

在此处输入图像描述

于 2020-03-19T18:57:30.473 回答
1

Plesk 管理员,请禁用 Web 应用程序防火墙以解决此问题。

Tools & Settings > Web Application Firewall > Turn Off

干杯!

于 2021-03-08T22:01:44.723 回答
0

Colin 的提示让我看到了我的新虚拟主机(InterServer)。原来他们的 Web 应用程序防火墙是罪魁祸首。将其切换为仅检测或关闭,就可以了。

于 2019-12-31T15:42:25.960 回答