我正在创建一个网络应用,我正在使用以下网络服务
[WebMethod]
[ScriptMethod(UseHttpGet = true)]
public void insertarea(string comname, string brandname, string zone, string location, string area)
{
string id = "";
var json = "";
SqlCommand cmdcom = new SqlCommand("select id from companydetails where comname='" + comname + "'", con);
con.Open();
SqlDataReader drcom = cmdcom.ExecuteReader();
while (drcom.Read())
{
id = drcom["id"].ToString();
}
con.Close();
List<object> addarea = new List<object>();
if (brandname != "select")
{
cmd = new SqlCommand("Insert into companyallot values('" + id + "','" + location + "','" + area + "','" + zone + "','" + brandname + "',NULL,NULL,NULL,NULL,NULL)", con);
con.Open();
cmd.ExecuteNonQuery();
json = js.Serialize("Area Added with brandname");
con.Close();
}
else
{
cmd = new SqlCommand("Insert into companyallot values('" + id + "','" + location + "','" + area + "','" + zone + "',Null,Null,Null,Null,Null,Null)", con);
con.Open();
cmd.ExecuteNonQuery();
json = js.Serialize("Area Added For All Brands");
con.Close();
}
Context.Response.Write("{" + '"' + "info" + '"' + ":" + json + "}");
}
但我不断收到错误
System.InvalidOperationException:insertarea Web服务方法名称无效。 在System.Web.Services.Protocols.HttpServerProtocol.Initialize() 在System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type,HttpContext context,HttpRequest request,HttpResponse response,Boolean&amp; abortProcessing)
我尝试了几次更改方法名称,但仍面临同样的错误。 有人知道这里有什么问题吗?
这是我的angularjs
函数
$scope.updatefunction = function (param) {
$scope.updateparam = param;
console.log($scope.updateparam.comarea);
$http.get('/allotcompany.asmx/areaintable', {
params: {
comname: $scope.mdcomname,
brandname: $scope.mdbrandname,
zone: $scope.mdzone,
location: $scope.location,
area: $scope.updateparam.comarea
}
}).then(function (response) {
alert(response.data.info);
$scope.gettableinfo();
});
}
答案 0 :(得分:0)
当我查看你的Angularjs代码时,我发现你称之为'beaintable&#39;方法名称$http.get('/allotcompany.asmx/areaintable'
。
将其更改为$http.get('/allotcompany.asmx/insertarea'