Reasons why WebResources could not be found

Hi, I had a problem running an embedded js file.

I tried all of the following:

  • Starting the Cassini Development Server (VS2008, .NET 3.5)
  • Added [assembly: WebResource ("MyNamespace.MyScriptFile.js", "text / javascript")] over the declaration of the class namespace.
  • Script The file has an action of the "Embedded Resource" assembly.
  • Trial registration during OnInit, OnLoad and OnPreRender
  • The script file is in the same assembly and namespace as the control that registers it.
  • The assembly with Reflector is open and the resource name is confirmed.
  • Doesn't work using one of the following methods:

    ScriptManager.RegisterClientScriptResource(Page, GetType(), "MyNamespace.MyScriptFile.js");
    
    Page.ClientScript.RegisterClientScriptResource(GetType(), "MyNamespace.MyScriptFile.js");
    
    Page.ClientScript.RegisterClientScriptInclude(GetType(), "key",
        Page.ClientScript.GetWebResourceUrl(GetType(), "MyNamespace.MyScriptFile.js"));
    
    • Other WebResource.axd files are located - only this one was not found.

404 : "*[HttpException]: This is an invalid webresource request.*"

ScriptManager.RegisterClientScriptResource :

"*Web resource 'MyNamespace.MyScriptFile.js' was not found.*"
+3
4

ScriptManger, .

public class MyScriptManager : System.Web.UI.ScriptManager
{
    protected override void OnInit(EventArgs e)
    {
            base.OnInit(e);
            RegisterClientScriptResource(this, typeof(ScriptManagerExtension), "MyNamespace.MyScriptFile.js");
    }
}
+1

GetType()... . , GetType(), , , . ASP.NET , GetType() , , ASP.NET.

typeof (SomeType), SomeType (, , ).

+3

Perhaps your resource file is inside the folder (s) in the project? If so, you must specify a different name / location string in the assembly and when you register the script

Page.ClientScript.RegisterClientScriptResource(GetType(), "MyNamespace.Folder1.Folder2.MyScriptFile.js");

[assembly: WebResource("MyNamespace.Folder1.Folder2.MyScriptFile.js", "text/javascript")]

usually that common problem

+2
source

An alternative reason for this problem is that you passed your Global.asax too hard and you said that everything else after your rules gives you the home page. It's not so smart that an hour or two is spent on it!

0
source

Source: https://habr.com/ru/post/1721148/


All Articles