简体   繁体   English

在DNN模块中嵌入资源给出了404

[英]Embedding resource in DNN module gives 404

I'm trying to embed a javascript file in a DNN module, the script tag is created but the content is a 404 error. 我正在尝试在DNN模块中嵌入javascript文件,创建了脚本标签,但内容是404错误。

The namespace of my project is "Carroussel" the location of my file is "js/jquery-carouFredSel-6.2.1.js" 我的项目的名称空间是“ Carroussel”,文件的位置是“ js / jquery-carouFredSel-6.2.1.js”

I've added the following code to AssemblyInfo.cs 我已将以下代码添加到AssemblyInfo.cs

[assembly: WebResource("Carroussel.js.jquery-carouFredSel-6.2.1.js", "application/javascript", PerformSubstitution = true)]

And the following to the OnInit of the module: 并将以下内容传递给模块的OnInit:

protected override void OnInit(EventArgs e)
{
    base.OnInit(e);

    Page.ClientScript.RegisterClientScriptResource(GetType(), "Carroussel.js.jquery-carouFredSel-6.2.1.js");
}

The scripttag is created in my html: 该脚本标记是在我的html中创建的:

<script src="/WebResource.axd?d=gnpD_kHZKrDN3DKUCn2faE-x6tdus2cDJ1HjymfAToCQgqX2ggJno51OH2VqPx8ArZPoUm5RuWxhg8uAOTZaysKJE7jz3kpB6gHWbD25o2plphslAJao3Rs5ybJz_M9vLB1NmgPujgOBCt3pDGs9aY_lTy04oPXMqX6dyz0AHhjrbZlKl8muO0ZRGnAiWwdicmeAlg2&amp;t=635349640675857733" type="text/javascript"></script>

But as soon as I view the source i get: 但是,一旦我查看了源代码,我就会得到:

The resource cannot be found.

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly. 

Requested URL: /WebResource.axd

Any ideas on what to change to make this working? 有什么想法可以使它起作用吗?

I would recommend that you not embed it, but let DNN handle the registration/loading of the resource. 我建议您不要嵌入它,而是让DNN处理资源的注册/加载。 Doing so will allow you to easily see references to the JS if you have CDF disabled in DNN, and mask the references and have the content minified with CDF enabled in DNN. 如果您在DNN中禁用了CDF,这样做可以使您轻松查看对JS的引用,并屏蔽引用,并在DNN中启用CDF来缩小内容。

Here is how to reference the client resource manager in DNN. 这是在DNN中引用客户端资源管理器的方法。

override protected void OnInit(EventArgs e)
{
      DotNetNuke.Framework.jQuery.RequestUIRegistration();
      ClientResourceManager.RegisterScript(Parent.Page, "~/Resources/Shared/scripts/knockout.js");
      ClientResourceManager.RegisterScript(Parent.Page, "~/desktopmodules/DnnChat/scripts/moment.min.js");
      ClientResourceManager.RegisterScript(Parent.Page, "~/desktopmodules/DnnChat/scripts/DnnChat.js",150);
      base.OnInit(e);
}

pulled from https://github.com/ChrisHammond/dnnCHAT/blob/master/View.ascx.cs https://github.com/ChrisHammond/dnnCHAT/blob/master/View.ascx.cs中拉出

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM