System.web does not contain a definition for the script

The script namespace type or name does not exist in the System.Web namespace (do you miss the assembly reference?)

it gives an error in the next line "System.Web.Script.Services.ScriptService"

I have included the system.web namespace

+4
source share
4 answers

Two problems:

  • The System.Web.Script.Services.ScriptServiceAttribute class exists in the System.Web.Extensions assembly, not System.Web . Make sure you reference the System.Web.Extensions assembly in your project.
  • With an explicit reference to the attribute, you must provide the full name "ScriptServiceAttribute", and not just "ScriptService".

As soon as I reference System.Web.Extensions, the following compiled for me:

 System.Web.Script.Services.ScriptServiceAttribute ss; 
+10
source

Google is your best friend. MSDN second.

Class ScriptServiceAttribute

Namespace: System.Web.Script.Services

Build: System.Web.Extensions (in System.Web.Extensions.dll )

Have you added a link to this dll?

+6
source

look in C: \ Program Files (x86) \ Microsoft ASP.NET \ ASP.NET 2.0 AJAX Extensions \ v1.0.61025 \ and see if you find System.Web.Extensions.dll or the path if you don't have dll, you can download and install ASP.NET AJAX 1.0 from http://www.microsoft.com/en-us/download/details.aspx?id=883

+1
source

Add targetFramework to the web.config file.

 <compilation debug="false" strict="false" explicit="true" **targetFramework="4.0"** /> 

This usually happens when you port codes, in particular web methods, from an older version, say .net 3.5, to a newer version.

Arun

+1
source

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


All Articles