Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scriptreference named respond no longer works

Using: Visual Studio Express 2013 for Web to write a .NET 4.5.1 site.

Project initially built on the default "Create New Website" template therefore the parts in question were added to my project by the IDE and have not been edited.

This has been a several weeks long project and today I began receiving an error out of the blue in relation to "canned" items added at create time. It has been working without error until now.

The error message is:

Server Error in '/' Application.  

'respond' is not a valid script name.  The name must end in '.js'.

I have debugged this to be directly related to this line in my site.master file:

<asp:ScriptReference Name="respond" />

SEE COMMENT HERE This reference is contained in the section of my master file:

This is part of the much larger group of scriptreferences added by the IDE at create time.

In troubleshooting I have tried adding the .js; add a path attribute to the actual file; and commented out the line entirely.

Adding the extension and/or the path results in a different error:

Server Error in '/' Application.

The assembly 'System.Web.Extensions, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' does not contain a Web resource that
has the name 'respond.js'. Make sure that the resource name is spelled correctly.

The only successful troubleshooting has been commenting it out BUT this breaks another key feature: Accessing my links requires the .ASPX extension now as previously I could access my links without specifying the extension on my file... and this is the default way the project was created via the ide, so with this fix in place, none of my links work without editing each and every one to include and extension. NOT IDEAL.

I've tried using the Package Manager to update and nothing has been successful there. I have also verified the respond.js file exists in my scripts folder as do the others like bootstrap.

I have searched here and googled for quite some time but there are so many unrelated results that contain excerpts from the scriptmanager that the results are endless.

I am unsure of the correction needed for this or if other files are required. Rebuilding my site has no effect, I've removed "temp" files per one post I read that said it might work for a different but similar issue.

What is the corrective action for this error?

like image 676
Adam Wood Avatar asked Apr 05 '14 18:04

Adam Wood


3 Answers

In Site.Master file locate the line:

<asp:ScriptReference Name="respond"/>

and modify to:

<asp:ScriptReference Name="respond" Assembly="System.Web.Extensions" />
like image 172
sam Avatar answered Sep 29 '22 22:09

sam


I ran into this same issue myself and fixed it by doing the following.

Add the following code to the RegisterBundles method of the BundleConfig class:

ScriptManager.ScriptResourceMapping.AddDefinition(
                "respond",
                new ScriptResourceDefinition
                {
                    Path = "~/Scripts/respond.min.js",
                    DebugPath = "~/Scripts/respond.js",
                });
like image 26
Aaron0 Avatar answered Sep 29 '22 23:09

Aaron0


I had the same problem, and none of the above worked... Verify your global.asax.cs, the Routeconfig and BundleConfig lines were missing in my case, after adding them, it worked again.

    void Application_Start(object sender, EventArgs e)
    {
        // Code that runs on application startup
        RouteConfig.RegisterRoutes(RouteTable.Routes);
        BundleConfig.RegisterBundles(BundleTable.Bundles);
    }
like image 35
snookie Avatar answered Sep 29 '22 23:09

snookie