网络服务可以在我的电脑上运行,但不能在服务器电脑上运行

时间:2018-09-03 10:30:44

标签: c# sql-server web-services iis

System.InvalidOperationException: Missing parameter: AracMarka.
at System.Web.Services.Protocols.ValueCollectionParameterReader.Read(NameValueCollection collection)
at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters()
at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()

我的WebMethot的参数可以在我的电脑上使用。我写了一些东西并作出回应,但是我将Web服务工作上传到服务器,但是当ı调用metod并向其中写入时,会出现错误Missing Parameter

我的PC本地服务器,服务器和代码

c

[WebMethod]
public Bilgiler GetBilgiForMarka(String AracMarka, String AracModel, String Motor)
{
    string a = "Data Source=.;Initial Catalog=Android;Integrated Security=True;MultipleActiveResultSets=True;Application Name=EntityFramework";
    Bilgiler bilgilerimiz = new Bilgiler();

    SqlConnection conn = new SqlConnection(a);
    SqlCommand command = new SqlCommand("SELECT ID FROM [Android].[dbo].[KitAracModel] WHERE AracMarka='" + AracMarka + "' AND AracModel='" + AracModel + "' AND Motor='" + Motor + "'");
    command.Connection = conn;
    conn.Open();
    int ax = (int)command.ExecuteScalar();

    conn.Close();

    using (SqlConnection con = new SqlConnection(a))
    {
        SqlCommand cmd = new SqlCommand("SP_BILGILERIGET", con);
        cmd.CommandType = System.Data.CommandType.StoredProcedure;
        SqlParameter parametre = new SqlParameter();
        parametre.ParameterName = "@ID";
        parametre.Value = ax;
        cmd.Parameters.Add(parametre);
        con.Open();
        SqlDataReader DR = cmd.ExecuteReader();
        while (DR.Read())
        {

            bilgilerimiz.ID = Convert.ToInt32(DR["ID"]);
            bilgilerimiz.AracMarka = DR["AracMarka"].ToString();
            bilgilerimiz.AracModel = DR["AracModel"].ToString();
            bilgilerimiz.Motor = DR["Motor"].ToString();
            bilgilerimiz.Silindir = DR["Silindir"].ToString();
            bilgilerimiz.Guc = DR["Guc"].ToString();
            bilgilerimiz.KitAd = DR["KitAd"].ToString();
            bilgilerimiz.KitNo = DR["KitNo"].ToString();
        }
    }
    return bilgilerimiz;
}

1 个答案:

答案 0 :(得分:0)

看起来生成的请求在本地和服务器上是不同的。我建议您使用Fiddler之类的网络流量记录工具在本地和服务器上运行该请求时,将其匹配。