c# - The following code always fails with 400 bad request -
function sendeditcommand() { jquery.ajax({ url: 'http://localhost:15478/service.svc/gettest', type: 'get', contenttype: "application/json; charset=utf-8", datatype: "json", success: function () { alert('success'); }, error: function(request, status, error) { alert(error); } }); } jquery(document).ready(function () { sendeditcommand(); }); <configuration> <system.web> <compilation debug="true" targetframework="4.0" /> </system.web> <connectionstrings> <add name="entities" connectionstring="metadata=res://*/data.techiecms.csdl|res://*/data.techiecms.ssdl|res://*/data.techiecms.msl;provider=system.data.sqlclient;provider connection string="data source=localhost\mssql2008;initial catalog=techiecms;integrated security=true;multipleactiveresultsets=true"" providername="system.data.entityclient" /> </connectionstrings> <system.servicemodel> <services> <service name="defaultservice" behaviorconfiguration="defaultservicebehavior"> <endpoint address="" binding="webhttpbinding" contract="techie.cms.business.contentprovider" behaviorconfiguration="defaultendpointbehavior" /> <endpoint address="mex" binding="mexhttpbinding" contract="imetadataexchange" /> </service> </services> <behaviors> <endpointbehaviors> <behavior name="defaultendpointbehavior"> <enablewebscript /> </behavior> </endpointbehaviors> <servicebehaviors> <behavior name="defaultservicebehavior"> <servicemetadata httpgetenabled="true" /> <servicedebug includeexceptiondetailinfaults="true"/> </behavior> </servicebehaviors> </behaviors> <servicehostingenvironment aspnetcompatibilityenabled="true" /> </system.servicemodel> </configuration> [servicecontract] [aspnetcompatibilityrequirements(requirementsmode = aspnetcompatibilityrequirementsmode.allowed)] public class contentprovider { [operationcontract] [webget()] public string gettest() { return "test"; } }
im guessing not port within url. else correct. using ie? work other browsers? other people same problem have been using ie , works on firefox.
perhaps try adding data variable , changing post? solves it.
Comments
Post a Comment