Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

how to solve Microsoft JScript runtime error: Sys.Net.WebServiceFailedException: The server method 'GetSlides' failed with the following error during usage of Ajax slideshowextender control in asp.net

Mar 22, 2011
Introduction:

Here I will explain how to solve the problem
Microsoft JScript runtime error: Sys.Net.WebServiceFailedException: The server method 'GetSlides' failed with the following error: during use of Ajax Slideshow extender control to display images from root folder using asp.net

Description:

In previous post I explained clearly how to show slideshow using AjaxSlideshowExtender control from root folder in asp.net check here . During working with Ajax SlideshowExtender I got error like
Microsoft JScript runtime error: Sys.Net.WebServiceFailedException: The server method 'GetSlides' failed with the following error: <html><head>
 To solve this problem I check my code and I found my mistake that problem is because of I forgot to declare the WebMethod and ScriptMethod
We need to write webmethods in below format only and use exact parameters that should be same as whatever I mentioned in web method
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public AjaxControlToolkit.Slide[] GetSlides()
{
……
……
}
In this web method we have a chance to change GetSlides method name only but return type and parametername should match and don’t forgot to mention this WebMethod and ScriptMethod above our GetSlides method the exception occurred because of missing these webmethods declaration.
Sometimes this problem occurs because of below line missing in code also

[System.Web.Script.Services.ScriptService]
By default this line is commented in webservice page we need to uncomment that line.
If we need to get the slideshow webservice method without errors our webservice page code looks like this 

/// <summary>
/// Summary description for Slideshow
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]

public class Slideshow : System.Web.Services.WebService {

public Slideshow () {

//Uncomment the following line if using designed components
//InitializeComponent();
}

[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public AjaxControlToolkit.Slide[] GetSlides()
{
string[] imagenames = System.IO.Directory.GetFiles(Server.MapPath("~/Images"));
AjaxControlToolkit.Slide[] photos = new AjaxControlToolkit.Slide[imagenames.Length];
for (int i = 0; i < imagenames.Length; i++)
{
string[] file = imagenames[i].Split('\\');
photos[i] = new AjaxControlToolkit.Slide("Images/" + file[file.Length - 1], file[file.Length - 1], "");
}
return photos;
}
}
I hope it helps to solve your problem.

Happy Coding……….

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

7 comments :

Anjum Rizwi said...

I have done as you suggested but still I am getting the error.

I am trying load the user control dynamically. User control has lot of complex code Repeater inside repeater so many action button.

Suresh Manikandan said...

your codes helped more... thankyou

Anonymous said...

its still giving same error..
plz help me to solve it!

hermes said...

The error problem still exist.

home said...

I can not find the differences.

Mourya said...
This comment has been removed by the author.
Mourya said...

i had the same issue, i was calling a webservice method from javascript and got the error

Sys.Net.WebServiceFailedException: The server method '' failed with the following error:

it can be solved by adding following lines to web.config

stackoverflow(dot)com(slash)a(slash)1151993/1054978

Give your Valuable Comments

Other Related Posts

© 2010-2012 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.