I am currently working on developing an MVC web application in c# and implementing Typescript for the frontend. I have a controller method that receives a HttpPost request with a data model, which is automatically generated as a Typescript class using typelite.
Within my request data model, there are datetime fields. However, when sending a request to the backend, these datetime fields are serialized into string format like "Sun+Dec+25+2016+11:29:33+GMT+0100+(ora+solare+Europa+occidentale)". I would prefer these fields to be serialized into UTC datetime strings.
The Typescript code used to send the request is as follows:
$.ajax({
method: callingMethod,
url: urlToCall,
data: *dataValue,
beforeSend: function () {
self.BeforeAsyncAction();
},
})
.done(callbackDone)
.fail(callbackFail)
.always(self.CompleteAsyncAction);
}
The dataValue class has the following interface:
export class FileServiceModel extends Gedoc.WebApplication.ServiceModels.BaseServiceModel {
Allegato: Gedoc.WebApplication.ServiceModels.FileStreamServiceModel;
Attributi: Gedoc.WebApplication.ServiceModels.AttributoServiceModel[];
Descrizione: string;
DimensioneByte: number;
*DtIn: Date;
*DtRegistrazione: Date;
*DtUp: Date;
Id: number;
Tags: string;
Titolo: string;
}
- fields that need to be serialized into UTC datetime.
What is the best way to automatically serialize these fields?
Thank you and kind regards