Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebResource.axd blank or not found

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?

like image 332
taco Avatar asked Apr 08 '09 15:04

taco


3 Answers

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.

like image 175
Atanas Korchev Avatar answered Nov 17 '22 01:11

Atanas Korchev


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.

like image 29
shahkalpesh Avatar answered Nov 17 '22 00:11

shahkalpesh


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

like image 2
taco Avatar answered Nov 17 '22 00:11

taco