Well, after a week of trying just about everything I could find on here, and elsewhere, to resolve this problem, I'm finally flying the flag of surrender and opening this up to my better experienced fellows. Basically I have a simple intranet app that resides on a VMed Windows 2012 R2/IIS8 server, which also hosts SQL 2014(I know, I know). I'm trying to autocomplete on two textboxes from a SQL table. In VS2017 it works perfectly fine, but when I try running it from IIS8 I get a "Failed to load resource: the server responded with a status of 500 (Internal Server Error)" error. Here's the HTML:
<script type="text/javascript">
$(function () {
$("#<%=txtSAPLoc.ClientID%>").autocomplete({
source: function (request, response) {
var param = { locName: $('#<%=txtSAPLoc.ClientID%>').val() };
$.ajax({
method: "POST",
url: "CdtCreateRecord.aspx/GetLoc",
data: JSON.stringify(param),
dataType: "json",
contentType: "application/json; charset=utf-8",
dataFilter: function (data) { return data; },
success: function (data) {
response($.map(data.d, function (item) {
return {
value: item
}
}))
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(errorThrown);
}
});
},
minLength: 2
});
});
$(function () {
$("#<%=txtSAPInst.ClientID%>").autocomplete({
source: function (request, response) {
var param = { instName: $('#<%=txtSAPInst.ClientID%>').val() };
$.ajax({
method: "POST",
url: "CdtCreateRecord.aspx/GetInst",
data: JSON.stringify(param),
dataType: "json",
contentType: "application/json; charset=utf-8",
dataFilter: function (data) { return data; },
success: function (data) {
response($.map(data.d, function (item) {
return {
value: item
}
}))
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(errorThrown);
}
});
},
minLength: 2
});
});
</script>
And the relevant code behind:
[WebMethod]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public static List<string> GetLoc(string locName)
{
List<string> Loc = new List<string>();
string query = string.Format("SELECT DISTINCT loc FROM Locations WHERE loc LIKE '%{0}%'", locName);
using (SqlConnection con = new SqlConnection("Server=usmac2dgsyntax;Database=LREC_ADB;Trusted_Connection=Yes;"))
{
using (SqlCommand cmd = new SqlCommand(query, con))
{
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
Loc.Add(reader.GetString(0));
}
}
}
return Loc;
}
[WebMethod]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public static List<string> GetInst(string instName)
{
List<string> Inst = new List<string>();
string query = string.Format("SELECT DISTINCT inst FROM Institutions WHERE inst LIKE '%{0}%'", instName);
using (SqlConnection con = new SqlConnection("Server=usmac2dgsyntax;Database=LREC_ADB;Trusted_Connection=Yes;"))
{
using (SqlCommand cmd = new SqlCommand(query, con))
{
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
Inst.Add(reader.GetString(0));
}
}
}
return Inst;
}
This is a sampling of stackoverflow articles I previously consulted: