0

Autocomplete with jquery json with c#: The program works on local but not works on server.Why?

[WebMethod]

public List<string> GetAutoCompleteData(string prefixText)
{ 

...

here is the error:

Internal server error 500

and also this error:

Server Error in '/' Application.

Unknown web method GetAutoCompleteData. Parameter name: methodName

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: Unknown web method GetAutoCompleteData. Parameter name: methodName

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[ArgumentException: Unknown web method GetAutoCompleteData. Parameter name: methodName]
System.Web.Script.Services.WebServiceData.GetMethodData(String methodName) +539974
System.Web.Script.Services.RestHandler.CreateHandler(WebServiceData webServiceData, String methodName) +10
System.Web.Script.Services.RestHandler.CreateHandler(HttpContext context) +159
System.Web.Script.Services.RestHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated) +62
System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated) +47
System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execut e()

+334 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272

Shamson
  • 1
  • 2
  • please post your javascript as well to give some more context. – feathj Jun 06 '13 at 12:13
  • $(document).ready(function () { SearchText(); function SearchText() { $("#<%=txtEntWord.ClientID %>").autocomplete({ source: function (request, response) { $.ajax({ url: "EmployeeList.asmx/GetAutoCompleteData", type: "POST", dataType: "json", contentType: "application/json; charset=utf-8", data: "{ 'prefixText' : '" + $("#<%=txtEntWord.ClientID %>").val() + "'}", dataFilter: function (data) { return data; }, success: function (data) { response($.map(data.d, function (items) { return { label: items, value: items } Here please, and where is the problem? – Shamson Jun 06 '13 at 13:08

1 Answers1

0

Ok, now we are getting somewhere.

If I understand this correctly, you have implemented a webmethod within your asp.net website in an asmx file (something that we are also doing in one of our products as well). In order for this to work properly in IIS (works fine in development environment), you will need to configure your IIS to allow .asmx pages (add a handler mapping). You can do this directly in the IIS config, or in your web.config.

Here is another question for reference:

ASMX service works on development server, returns 404 when deployed to IIS 7.5

Disregard bounty thing. Different question :)

Community
  • 1
  • 1
feathj
  • 3,019
  • 2
  • 22
  • 22