我正在尝试使用 AJAX 将此对象放入 /api/company/#/:
{"CompanyID":2,"Name":"Test Company","Address1":"","Address2":"","City":"","State":"","Zip":"","ContactName":"","ContactPhone":"","ContactEmail":"","EmployeeCount":"","TypeOfIndustry":"","CompanyRevenue":""}
我的 PUT 方法:
public void Put (CompanyOverviewView company)
{
}
公司概况查看:
public class CompanyOverviewView {
public int CompanyID { get; set; }
public string Name { get; set; }
public string Address1 { get; set; }
public string Address2 { get; set; }
public string City { get; set; }
public string State { get; set; }
public string Zip { get; set; }
public string ContactName { get; set; }
public string ContactPhone { get; set; }
public string ContactEmail { get; set; }
public string CompanyType { get; set; }
public Nullable<int> EmployeeCount { get; set; }
public string TypeOfIndustry { get; set; }
public Nullable<decimal> CompanyRevenue { get; set; }
AJAX 属性:
var ajaxProperties = {
type: "PUT",
url: "/api/company/5/",
dataType: "json",
data: JSON.stringify(postdata)
}
尽管使用默认的 WebAPI 路由,但我收到 404 错误。为什么这不挂钩?我错过了什么吗?