Asp.net mvc JSON不是';t绑定到我的模型

Asp.net mvc JSON不是';t绑定到我的模型,asp.net-mvc,asp.net-mvc-4,Asp.net Mvc,Asp.net Mvc 4,jQuery: var mmr = new Mmr.FormData().mmr; $.ajax({ contentType: 'application/json; charset=utf-8', url: "/Property/Mmr/Submit", data: JSON.stringify(mmr), success: function () { alert("success");

jQuery:

var mmr = new Mmr.FormData().mmr;
    $.ajax({
        contentType: 'application/json; charset=utf-8',
        url: "/Property/Mmr/Submit",
        data: JSON.stringify(mmr),
        success: function () {
            alert("success");
        },
        dataType: "json",
        method: "POST",
        error: function () {
            alert("failure");
        }
    });
我的控制器:

[HttpPost]
public string Submit(MonthlyMarketingReport report)
{
    return "SUCCESS";
}
报告中的所有数据都是空的。我不知道为什么

这是发布的json。。。(它来自从c#模型转换而来的TypeScript类,因此这应该是正确的…)

我的月度营销报告课

public partial class MonthlyMarketingReport : Reports
{
    public Nullable<int> MarketingPlanId { get; set; }
    public bool IsMarketedWhileOccupied { get; set; }
    public string IsMarketedWhileOccupiedExplain { get; set; }
    public bool IsCodeViolation { get; set; }
    public string IsCodeViolationExplain { get; set; }
    public bool IsForSaleSign { get; set; }
    public string IsForSaleSignExplain { get; set; }
    public bool IsClean { get; set; }
    public string IsCleanExplain { get; set; }
    public bool IsTrashout { get; set; }
    public string IsTrashoutExplain { get; set; }
    public bool IsUtilitiesOn { get; set; }
    public string IsUtilitiesOnExplain { get; set; }
    public bool IsWinterized { get; set; }
    public string IsWinterizedExplain { get; set; }
    public bool IsHazard { get; set; }
    public string IsHazardExplain { get; set; }
    public bool IsRepairsCompleted { get; set; }
    public string IsRepairsCompletedExplain { get; set; }
    public bool IsVandalized { get; set; }
    public bool IsInsuranceClaim { get; set; }
    public string CurrentCondition { get; set; }
    public int Showings { get; set; }
    public int ShowingsTotal { get; set; }
    public System.DateTime TourDateLast { get; set; }
    public System.DateTime OpenHouseDateLast { get; set; }
    public string CommentsBuyerPositive { get; set; }
    public string CommentsBuyerNegative { get; set; }
    public bool IsRepairsRecomended { get; set; }
    public string IsRepairsReccomendedExplain { get; set; }
    public Nullable<decimal> IsRepairsEstimate { get; set; }
    public bool IsFinanced { get; set; }
    public string IsFinancedExplain { get; set; }
    public string NotSoldExplain { get; set; }
    public int LocalListingsCount { get; set; }
    public int LocalDaysOnMarketAverage { get; set; }
    public decimal LocalPriceLow { get; set; }
    public decimal LocalPriceHigh { get; set; }
    public string LocalCompetition { get; set; }
    public string LocalCondition { get; set; }
    public string LocalPriceRange { get; set; }
    public string MarketingStrategy { get; set; }
    public decimal PriceRecommended { get; set; }
    public int CompIdRecentSale1 { get; set; }
    public int CompIdRecentSale2 { get; set; }
    public int CompIdRecentSale3 { get; set; }
    public int CompIdCurrentListing1 { get; set; }
    public int CompIdCurrentListing2 { get; set; }
    public int CompIdCurrentListing3 { get; set; }

    public virtual Comparables RecentSale1 { get; set; }
    public virtual Comparables RecentSale2 { get; set; }
    public virtual Comparables RecentSale3 { get; set; }
    public virtual Comparables CurrentListing1 { get; set; }
    public virtual Comparables CurrentListing2 { get; set; }
    public virtual Comparables CurrentListing3 { get; set; }
    public virtual Album Album { get; set; }
}
public分部类MonthlyMarketingReport:Reports
{
公共可为空的MarketingPlanId{get;set;}
公共布尔值是marketedwhileoccupied{get;set;}
公共字符串为marketedwhileoccupiedexplain{get;set;}
公共bool iscode冲突{get;set;}
公共字符串IsCodeViolationExplain{get;set;}
公共bool IsForSaleSign{get;set;}
公共字符串IsForSaleSignExplain{get;set;}
公共bool IsClean{get;set;}
公共字符串IsCleanExplain{get;set;}
公共布尔IsTrashout{get;set;}
公共字符串IsTrashoutExplain{get;set;}
公共bool是{get;set;}上的实用程序
公共字符串IsUtilitiesOneExplain{get;set;}
公共布尔值已冬化{get;set;}
公共字符串IsWinterizedExplain{get;set;}
公共bool IsHazard{get;set;}
公共字符串IsHazardExplain{get;set;}
公共布尔值已完成{get;set;}
公共字符串IsRepairsCompletedExplain{get;set;}
公共场所被破坏{get;set;}
公共布尔值是insuranceclaim{get;set;}
公共字符串当前条件{get;set;}
公共整数显示{get;set;}
public int ShowingsTotal{get;set;}
public System.DateTime TourDateLast{get;set;}
public System.DateTime OpenHouseDateLast{get;set;}
公共字符串CommentsBuyerPositive{get;set;}
公共字符串CommentsBuyerNegative{get;set;}
公共bool是repairsreded{get;set;}
公共字符串IsRepairsRecommendedExplain{get;set;}
公共可为Null的IsRepairsEstimate{get;set;}
公共布尔值{get;set;}
公共字符串IsFinancedExplane{get;set;}
公共字符串notsoldexplane{get;set;}
public int LocalListingsCount{get;set;}
public int LocalDaysOnMarketAverage{get;set;}
公共十进制LocalPriceLow{get;set;}
公共十进制LocalPriceHigh{get;set;}
公共字符串LocalCompetition{get;set;}
公共字符串LocalCondition{get;set;}
公共字符串LocalPriceRange{get;set;}
公共字符串营销策略{get;set;}
公共十进制价格建议{get;set;}
public int CompIdRecentSale1{get;set;}
public int CompIdRecentSale2{get;set;}
public int CompIdRecentSale3{get;set;}
public int CompIdCurrentListing1{get;set;}
public int CompIdCurrentListing2{get;set;}
public int CompIdCurrentListing3{get;set;}
公共虚拟可比数据RecentSale1{get;set;}
公共虚拟可比数据最近出售2{get;set;}
公共虚拟可比数据最近出售3{get;set;}
公共虚拟可比数据CurrentListing1{get;set;}
公共虚拟可比数据CurrentListing2{get;set;}
公共虚拟可比数据CurrentListing3{get;set;}
公共虚拟相册相册{get;set;}
}

控制器操作方法的签名为

public string Submit(MonthlyMarketingReport report)
所以我认为在你的ajax调用中应该是

data: JSON.stringify({ report: mmr }),

请提供您的
MonthlyMarketingReport
类代码。您是否在fiddler或web调试器中检查过API url是否良好,即调用/Property/Mmr/Submit时没有收到404错误?@ErikPhilips对此表示抱歉,现在添加了。@Brian url正常,因为它进入了控制器,只是模型为空且其中没有数据。请尝试将
数据:JSON.stringify(mmr),
更改为
mmr
。只需发送对象。您只发送了一个字符串。我尝试了一下,但没有成功,它没有以这种方式进入控制器,很遗憾=/。
data: JSON.stringify({ report: mmr }),