Note that there are some explanatory texts on larger screens.

plurals
  1. POError 500 when calling asmx service from javascript
    primarykey
    data
    text
    <p>I am calling a .net 2.0 asmx service using javascript and servicereference. When I call the service in the test environment and locally, everything works fine. In production I get an error 500. I don't see any errors in the event log or displayed anywhere.</p> <p>If I hit the web service directly then I receive the json formatted data. If I call the web service from javascript using the servicereference then I get the error 500. </p> <p>I think this might be related to a size limitation since I can reduce the number of datapoints and the data is returned through javascript correctly.</p> <p>I have tried increasing the maxRequestLength in httpRuntime but that doesn't have any affect. Is there some setting that I am missing?</p> <p>If you view this page: <a href="http://bit.ly/NXBFpD" rel="nofollow">http://bit.ly/NXBFpD</a> you will see that data is returned without an error.</p> <p>If you view this page and watch the calls being made in firebug you'll see that the same page as above is called, but an error 500 is returned. <a href="http://bit.ly/NXBPO1" rel="nofollow">http://bit.ly/NXBPO1</a></p> <p>This is the code-behind on the page being called:</p> <pre><code>protected void Page_Load(object sender, EventArgs e) { if(!IsPostBack) { ScriptManager.GetCurrent(Page).Services.Add(new ServiceReference("/Services/FusionService.asmx")); } } } </code></pre> <p>This is the js code calling the service:</p> <pre><code>function GetGeometries(sw, ne, metro) { FusionService.GetGeometries(sw.lat(), sw.lng(), ne.lat(), ne.lng(), metro, drawMap); } </code></pre> <p>This is the service:</p> <pre><code>[WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.Web.Script.Services.ScriptService] public class FusionService : System.Web.Services.WebService { private string url = "https://www.googleapis.com/fusiontables/v1/query"; [WebMethod] [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)] public string GetGeometries(decimal southWestLat, decimal southWestLng, decimal northEastLat, decimal northEastLng, string metro) { try { var jss = new JavaScriptSerializer(); string key = string.Format("Geometry-{0}", metro); var geometryData = HttpContext.Current.Cache[key] as string; if (!string.IsNullOrEmpty(geometryData)) { var deserialized = jss.Deserialize&lt;GeometryData&gt;(geometryData); return jss.Serialize(deserialized); } var query = "SELECT name, geometry, FranchiseI, latitude, longitude, STATE FROM " + "1JNOz_lhP1B8oCzeNLBm8u5k6ezdRDKtM-NBD8 where ST_INTERSECTS(geometry, RECTANGLE(LATLNG(" + southWestLat + "," + southWestLng + "), LATLNG(" + northEastLat + "," + northEastLng + ")))"; var requestString = url + "?sql=" + HttpUtility.UrlEncode(query) + "&amp;key=AIzaSyCXLd2VlvZ0FNLbgMKsfSq7Uvp3IDwa"; var request = WebRequest.Create(requestString) as HttpWebRequest; using (var response = request.GetResponse() as HttpWebResponse) { var reader = new StreamReader(response.GetResponseStream()); var json = reader.ReadToEnd(); json = json.Replace("NaN", "\"\""); HttpContext.Current.Cache[key] = json; var deserialized = jss.Deserialize&lt;GeometryData&gt;(json); return jss.Serialize(deserialized); } } catch(Exception ex) { return ex.Message; } } </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload