Skip to content

Web Service Error – InvalidOperationException

August 30, 2013

If you ever receive a web service error containing InvalidOperationException in the content, like the following error message below: –

<!–
[InvalidOperationException]: Only Web services with a [ScriptService] attribute on the class definition can be called from script.
   at System.Web.Script.Services.WebServiceData..ctor(Type type, Boolean pageMethods)
   at System.Web.Script.Services.WebServiceData.GetWebServiceData(HttpContext context, String virtualPath, Boolean failIfNoData, Boolean pageMethods, Boolean inlineScript)
   at System.Web.Script.Services.RestHandler.CreateHandler(HttpContext context)
   at System.Web.Script.Services.RestHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated)
   at System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated)
   at System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig)
   at System.Web.HttpApplication.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
–>

“NetworkError: 500 Internal Server Error – http://localhost:49332/&#8221;

 

Then the main reason is that you have not set in the web service asmx file correctly by un-commenting the script service reference.

So uncomment [System.Web.Script.Services.ScriptService] to allow this Web Service to be enabled.

As in the asmx file.

    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
    // [System.Web.Script.Services.ScriptService]

Advertisements

From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: