asp.net mvc - Bad AJAX response, return a document in web service -


i have simple web service debbug , have correct answer, code is:

 [webmethod]         [scriptmethod(responseformat = responseformat.json)]         public string getuserid()         {             var windowsuserdomain = system.web.httpcontext.current.user.identity.name;             var windowsuser = windowsuserdomain.split('\\')[1];             iuser user = zamba.core.userbusiness.getuserbyname(windowsuser);              //this.context.response.contenttype = "application/json; charset=utf-8";              //javascriptserializer jsonserialiser = new javascriptserializer();             //return jsonserialiser.serialize(jsonlist);         return           newtonsoft.json.jsonconvert.serializeobject(user);          } 

when open ws in chrome have code:

this xml file not appear have style information associated it. document tree shown below. <string xmlns="http://tempuri.org/"> {"password":"","crdate":"0001-01-01t00:00:00","lmoddate":"2014-04-16t00:00:00","expirationtime":0,"addressbook":"","expiredate":"20/07/2005","nombres":"dl","apellidos":"sri","puesto":"claims","telefono":"53","firma":"","picture":"\\\\server2008\\volumenes\\indanil.jpg","connectionid":0,"wflic":false,"email":{"type":1,"servidor":"","base":"","mail":"mauso@arc.com.ar","username":"mroc.com.ar","proveedorsmtp":"smtp.gmail.com","puerto":57,"password":""},"groups":[{"isfull":false,"isloaded":false,"state":0,"type":1,"description":"","users":[],"createdate":"","pictureid1":0,"name":"* claims","id":2145}],"pictureid1":0,"type":0,"description":"marsh s.a.","state":1,"isfull":false,"isloaded":false,"mailconfigloaded":false,"name":"sta","id":258} </string> 

but when call ws in js ajax in mode:

$.ajax({            type: "get",            async: false,   url: "services/usersinfo.asmx/getuserid",            success: function (d) {                thisuserid = d.user;            }        }); 

d = document in html, not json response, put in web.config code:

<add name="scripthandlerfactory"                  verb="*" path="*.asmx"                  type="system.web.script.services.scripthandlerfactory, system.web.extensions, version=4.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35"                  resourcetype="unspecified" /> 

but every time return document , not json response, cant "d.data" or $.json(d) because d document.

how can configure ws, ajax call or web config? thanks


Comments