Ajax Asmx Internal Server Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn asmx internal server error 500 more about Stack Overflow the company Business Learn more about hiring developers or posting internal server error ajax php ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community 500 internal server error ajax get Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up ASP.NET + jQuery AJAX - getting 500 server error up
500 Internal Server Error When Calling Web Service
vote 0 down vote favorite I want to call an ASP.NET function from jQuery by AJAX with response. I have file Controll.aspx where is included javascript code. Next I have /Services/ControllService.asmx, where is the function, which I want call from js. js code: $(document).ready(function () { $('#btn_start').on('click', function () { $.ajax({ type: "POST", url: "Services/ControllService.asmx/Start", data: {}, dataType: "json", async: true, contentType: "application/json; charset=utf-8", success: function (response) { console.log(response); 500 internal server error when calling webservice with jquery }, error: function (err) { alert("Error:" + err.toString()); } }); }); }); But I still getting the error 500. POST http://localhost:56000/Services/ControllService.asmx/Start 500 (Internal Server Error) k.cors.a.crossDomain.send n.extend.ajax Do you have any hints, what do I need to set e.g. in Web.config? Many thanks. c# jquery asp.net ajax share|improve this question edited Apr 25 '15 at 17:12 panther 14.2k71942 asked Apr 13 '15 at 21:09 DzeryCZ 12119 1 Could you post your C# method Start –Frayt Apr 13 '15 at 21:12 2 You should catch the exception in your code and this will give you more information. Or you can analyse the response body from the network inspector where you will see the error page that is generated.. –Laurent Lequenne Apr 13 '15 at 21:15 add a comment| 1 Answer 1 active oldest votes up vote 0 down vote accepted SOLVED: 1 - I have defined Start function in ControllService.asmx.cs as static. 2 - I have badly configured data. It has to be named by the same way e.g. "sth". In javascript it should be: ... url: "Services/ControllService.asmx/Start", data: JSON.stringify({ sth: "hahaha" }), dataType: "json", ... and in ControllService.asmx.cs -> method Start public string Start(string sth){} Many, many thanks for your hints
here for a quick overview of the site Help Center Detailed answers system invalidoperationexception request format is unrecognized for url unexpectedly ending in to any questions you might have Meta Discuss the workings
Fiddler
and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow http://stackoverflow.com/questions/29615146/asp-net-jquery-ajax-getting-500-server-error Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Internal Server Error when calling asmx web server with JSON up vote 2 down vote favorite I have created a simple web service and published http://stackoverflow.com/questions/21215520/internal-server-error-when-calling-asmx-web-server-with-json it to my host. When I call it directly via web browser, it is working. http://test.xxxx.com/service1.asmx/HelloWorld Then I have tried to call it from an aspx web page using the JSON response format but I'm getting an Internal Server Error. My service: [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] [System.Web.Script.Services.ScriptService] public class Service1 : System.Web.Services.WebService { [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public DataSet HelloWorld() { DataSet ds = new DataSet(); //da.Fill(ds); ds.Tables.Add("Table0"); ds.Tables[0].Columns.Add("Test"); for (int i = 0; i < 20; i++) { ds.Tables[0].Rows.Add("Test " + i); } return ds; } } And I'm calling it from the aspx page with below method. The above line would fail as the web service has been placed in sub directory called services Same line would succeed if we put out web service (.asmx) file in application Root Folder -- Tracking through Fiddler trace, notice we are making call to jsdebug Note : The "/jsdebug" suffix is used by AJAX to get the debug release of Javascript