Click here to Skip to main content
15,886,963 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
i called my action .asmx by method

JavaScript
ajaxCall: function (serverMethod, params, successHandler) {
       var csrfToken = $("input[name='__RequestVerificationToken']").val();
       //alert('csrfToken= ' + csrfToken);

       $.ajax({
           headers: { __RequestVerificationToken: csrfToken },
           cache: false,
           async: false,
           type: "POST",
           url: "Server/services/Actions.asmx/" + serverMethod + "?sid=" + app.sessionId,
           data: params,
           contentType: "application/json; charset=utf-8",
           dataType: "json",
           dataFilter: function (data) {
               var msg;

               if (typeof (JSON) !== 'undefined' && typeof (JSON.parse) === 'function')
                   msg = JSON.parse(data);
               else
                   msg = eval('(' + data + ')');

               if (msg.hasOwnProperty('d'))
                   return msg.d;
               else
                   return msg;
           },
           success: function (response) {

               if (!response) {
                   datacontext.log(response.statusText, response, this, 'error1');
               }

               successHandler(response);
               var j = response;
               //for (var i = 0; i < j.length; i++) {
               //    successHandler(j[i]);
               //}
           },
           error: function (xhr) {
               datacontext.log(xhr.statusText, xhr, this, 'error');
           }
       });
   },

it works well when i debug my project (Single Page Application) in vs2012
,even when i puplish my site on local iis in my pc
but when i puplish my website on iis on aremote server i got internal server error 500 when call ajaxcall method
and when i typed url of asmx (www.mysite.com/Server/services/Actions.asmx/GetNewsCount?sid=1)

i got this response on the browser




System.NotSupportedException: The type System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] is not supported because it implements IDictionary.
   at System.Xml.Serialization.TypeScope.GetDefaultIndexer(Type type, String memberInfo)
   at System.Xml.Serialization.TypeScope.ImportTypeDesc(Type type, MemberInfo memberInfo, Boolean directReference)
   at System.Xml.Serialization.TypeScope.GetTypeDesc(Type type, MemberInfo source, Boolean directReference, Boolean throwOnError)
   at System.Xml.Serialization.ModelScope.GetTypeModel(Type type, Boolean directReference)
   at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(Type type, XmlRootAttribute root, String defaultNamespace)
   at System.Web.Services.Protocols.XmlReturn.GetInitializers(LogicalMethodInfo[] methodInfos)
   at System.Web.Services.Protocols.XmlReturnWriter.GetInitializers(LogicalMethodInfo[] methodInfos)
   at System.Web.Services.Protocols.MimeFormatter.GetInitializers(Type type, LogicalMethodInfo[] methodInfos)
   at System.Web.Services.Protocols.HttpServerType..ctor(Type type)
   at System.Web.Services.Protocols.HttpServerProtocol.Initialize()
   at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)

please any one know how to solve this ?
Posted
Comments
Mostly it seems to be a Path issue. So, try like below once if it works or not, then we will try to fix the path issue.

url: "www.mysite.com/Server/services/Actions.asmx/" + serverMethod + "?sid=" + app.sessionId,
nagiub2007 15-Nov-13 10:49am    
but it works in localhost
Please do as I suggested. Let's try it first. It depends upon the deployment folder on Server.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900