【问题标题】:DNN WebResource.axd not found for custom control未找到自定义控件的 DNN WebResource.axd
【发布时间】:2013-08-17 12:34:46
【问题描述】:

我已经构建了一个自定义控件,并希望在其中添加一个嵌入式 js 文件。我认为我做的一切都是正确的,并且控件按预期编译。

我已将 js 文件标记为 Build Action "Embedded Resource"

简化控制:

[assembly: WebResource("GoogleMapsLegend.js", "application/javascript", PerformSubstitution = true)] 
namespace CustomControls
{
    public class GoogleMapsLegend : WebControl
    {
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            this.Page.ClientScript.RegisterClientScriptInclude(typeof(CustomControls.GoogleMapsLegend), "GoogleMapsLegend", Page.ClientScript.GetWebResourceUrl(typeof(CustomControls.GoogleMapsLegend), "GoogleMapsLegend.js")); 
        }
    }
}

当我在 DotNetNuke 环境中运行控件时,我得到一个 404

加载资源失败:服务器响应状态为 404(未找到) http://testenvironment.dev.nl/WebResource.axd?d=9ubkUMGTBWycKhgQIG5UHmzbPQjp5hcuPdO…jQr5YlIXdwqph6fJIVdtyKxWHJnyuIP44D9akltG8kiDFVFdwSND0&t=635122452802549563

我需要在 web.config 中添加其他设置吗?

我尝试将以下内容添加到 web.config,但到目前为止没有运气。

<add verb="*" path="WebResource.axd" validate="true" type="System.Web.Handlers.AssemblyResourceLoader" />

是否可能与 Telerik.Web.UI.WebResource.axd 存在冲突?

【问题讨论】:

    标签: asp.net custom-controls dotnetnuke webresource.axd


    【解决方案1】:

    我不确定,但看起来您用于注册脚本的行可能是错误的。 如果我在你有“GoogleMapsLegend.js”的地方是正确的,你需要它之​​前的命名空间/路径

    因此,如果文件位于“JavaScript”之类的子目录中,那么我认为应该是

    “命名空间.Javascript.GoogleMapsLegend.js”

    我在这里可能错了,但我过去曾为此使用过这篇文章:http://weblogs.asp.net/briandukes/archive/2009/06/08/embedding-javascript-and-other-resources-in-a-net-assembly.aspx

    【讨论】:

    • 完美运行!不知道它是名称空间或 RegisterClientScriptResource 而不是 RegisterClientScriptInclude 但它现在可以工作。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-07
    相关资源
    最近更新 更多