WebResource.axd 为空或未找到

发布于 2024-07-16 04:03:39 字数 795 浏览 4 评论 0原文

我正在尝试导出 .dll 中的控件库,以供办公室中的其他开发人员使用。

我最初创建的解决方案如下所示:

解决方案 1:
- Mri.Controls(类库)
- Mri.FmTool(Web 应用程序)

Mri.FmTool 引用 Mri.Controls。

在 Mri.Controls 中,我有一些 javascript WebResources。 Mri.FmTool 似乎可以很好地读取 WebResources,当 Mri.FmTool Web 应用程序运行时,我的所有 javascript Web 资源都按其应有的方式显示。

所以,现在我试图创建一个简单的解决方案来使用 Mri.FmTool

解决方案 2:
- Mri.ConsumerTest(Web 应用程序)

我采用了最新的 Mri.Controls.dll 并将其添加为对 Mri.ConsumerTest 应用程序的引用。 Mri.Controls 中的所有控件似乎都在 Mri.ConsumerTest 内运行。 智能感知正在工作,可以编译,没有问题。

但是,当运行它时,大多数 WebResource.axd 文件都是空的,只是空白。 一个 WebResource.axd 文件不是空白的,它只是说“找不到此资源”。

以下是“属性”窗口中 javascript 文件的属性:
构建操作:“嵌入式资源”
复制到输出目录:“始终复制”

我错过了什么步骤?

I'm trying to export a control library in a .dll for other developers in the office to consume.

The solution I original created looks like this:

Solution 1:
- Mri.Controls (Class Library)
- Mri.FmTool (Web Application)

Mri.FmTool references Mri.Controls.

Inside Mri.Controls, I have some javascript WebResources. Mri.FmTool seems to read the WebResources just fine, all my javascript web resouces appear as they should when Mri.FmTool web app is running.

So, now I was trying to create a simple solution to consume Mri.FmTool

Solution 2:
- Mri.ConsumerTest (Web Application)

I took the latest Mri.Controls.dll and added it as a reference to Mri.ConsumerTest application. All the controls from Mri.Controls seem to be working inside Mri.ConsumerTest. Intellisense is working, it compiles, no issues.

However, when running it, most of the WebResource.axd files are empty, just blank. One WebResource.axd file isn't blank, it simply says "This resource cannot be found."

Here are the properties of the javascript files inside the Properties window:
Build Action: "Embedded Resource"
Copy to Output Directory: "Copy always"

What step am I missing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

云朵有点甜 2024-07-23 04:03:39

您可能缺少 [ assembly:WebResource("YourNameSpace.YourFile.js", "text/javascript")] 属性。 WebResource.axd 需要该属性。 您可以查看知识库文章,了解有关此事的更多信息。

You are probably missing the [assembly:WebResource("YourNameSpace.YourFile.js", "text/javascript")] attribute. WebResource.axd needs that attribute. You can check this KB article for additional info on the matter.

鱼忆七猫命九 2024-07-23 04:03:39

资源是否设置为 DLL 的一部分?

打开解决方案 Mri.Controls & 查看 JavaScript 资源文件的属性。
我认为这可能就是问题所在。

Are the resources set to be part of the DLL?

Open the solution Mri.Controls & view the properties of your javascript resource files.
I think that is where the problem could be.

ぃ弥猫深巷。 2024-07-23 04:03:39

我注意到我的 WebResource CSS 文件加载正确,但 Javascript 没有在新解决方案的 WebResource 中加载。

因此,我没有使用 System.Web.UI.ClientScriptManager 来注册 WebResources,而是改用 System.Web.UI.脚本管理器。 现在,文件来自 ScriptManager.axd(而不是 WebResource.axd)。 这似乎解决了问题。

修复前的旧代码:

public class ScriptManagerExtension : System.Web.UI.ScriptManager
{
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        Page.ClientScript.RegisterClientScriptResource(this, typeof(ScriptManagerExtension), "Mri.Controls.Resources.Scripts.Libraries.jQuery.js");
    }
}

上面的代码片段使用 System.Web.UI.ClientScriptManager

修复后的新代码:

public class ScriptManagerExtension : System.Web.UI.ScriptManager
{
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        RegisterClientScriptResource(this, typeof(ScriptManagerExtension), "Mri.Controls.Resources.Scripts.Libraries.jQuery.js");
    }
}

上面的代码片段使用 System.Web.UI.ScriptManager

来自我的了解一下,ClientScriptManager是2.0中引入的。 我相信 ScriptManager 是管理脚本的新改进的 3.5 方式,具有更多功能。

/耸肩

I noticed that my WebResource CSS files were loading properly, but Javascript was not loading in WebResource in the new solution.

So, instead of using the System.Web.UI.ClientScriptManager used to register the WebResources, I switched over to using System.Web.UI.ScriptManager. Now the files are coming out of ScriptManager.axd (instead of WebResource.axd). This seemed to fix the problem.

Old Code before Fix:

public class ScriptManagerExtension : System.Web.UI.ScriptManager
{
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        Page.ClientScript.RegisterClientScriptResource(this, typeof(ScriptManagerExtension), "Mri.Controls.Resources.Scripts.Libraries.jQuery.js");
    }
}

The code snippet above uses System.Web.UI.ClientScriptManager

New Code after Fix:

public class ScriptManagerExtension : System.Web.UI.ScriptManager
{
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        RegisterClientScriptResource(this, typeof(ScriptManagerExtension), "Mri.Controls.Resources.Scripts.Libraries.jQuery.js");
    }
}

The code snippet above uses System.Web.UI.ScriptManager

From my understanding, ClientScriptManager was introduced in 2.0. I believe ScriptManager is the new improved 3.5 way of managing scripts that has a lot more functionality.

/shrug

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文