Utpal
Utpal

Reputation: 807

Datetime value sent in AJAX call is not deserializing in MVC controller

I am sending a datetime string in following format '22/03/17' in side a javascript object . But in MVC controller this value is not serializing and it is giving null value. In the C# class the property is defined like this.

public DateTime? SubscriptionExpiryDate { get; set; }

What I am doing wrong.

javascript is like this

var data = self;

            ajaxRequest("POST", baseUrl + controller + "SaveSubcription", self)
                .done(function (data, textStatus, jqXHR) {
                    if (data.Success == false) {

                        toastr.error('Problem in creating rule ', 'Error!')
                    }
                    else {
                        $(location).attr('href', baseUrl + "RuleEngine");
                        toastr.success('Rule saved successfully ', 'Success!');
                    }

                });

and Serializing class structure like this

public Guid SubscriptionId { get; set; }

    public Guid PlanId { get; set; }

    public Guid OrgId { get; set; }

    public decimal? PlanCost { get; set; }

    public decimal? AlrPlanCost { get; set; }

    public DateTime? SubscriptionStartDate { get; set; }

    public DateTime? SubscriptionExpiryDate { get; set; }

Thanks Utpal Maity

Upvotes: 0

Views: 657

Answers (1)

Prashant Hadole
Prashant Hadole

Reputation: 36

May your system date time format is not proper or you have to set culture in your MVC controller , so that it will get the value at the time of serialization

Upvotes: 0

Related Questions