Hello there! I am currently working on an MVC project with Angular where I am utilizing a JsonResult to return JSON data from a list containing emails with a specific date.
Below is the AJAX call I'm making from Angular:
myApp.service('mailService', function ($http) {
this.getEmailByDate = function (date) {
return $http.get("/Home/ShowEmailByDate/", { params: { date: date } });
};
});
This is my JsonResult in the Controller:
public JsonResult ShowEmailByDate(string date)
{
var selectedMsg = ClassHelper.listMsg;
var result = selectedMsg.Select(s => new
{
From = s.From.RawValue,
Date = s.Date.ToString("F"),
searchDate = s.Date.ToString("dd/MM/yyyy"),
sortDate = s.Date.ToString("M"),
sortTime = s.Date.ToString("t"),
Subject = s.Subject,
Body = s.BodyHtml,
Attachments = s.AttachmentFiles.Count(),
Files = s.AttachmentFiles.Select(f => f.FileName)
})
.Where(s => s.searchDate == date)
.OrderByDescending(s => s.sortDate)
.ThenByDescending(s => s.sortTime);
return Json(result, JsonRequestBehavior.AllowGet);
}
Now, the issue I'm facing seems to occur only in Internet Explorer. It works perfectly fine on Chrome and Firefox. The URL that I observe in developer mode under the Network tab when I trigger the AJAX call appears like this:
htttp://localhost:0000/Home/ShowEmailByDate/?date=%E2%80%8E23%E2%80%8E%2F%E2%80%8E12%E2%80%8E%2F%E2%80%8E2015
As a result, I receive an empty array response []
On the other hand, in Firefox and Chrome, the URL looks like this:
htttp://localhost:0000/Home/ShowEmailByDate/?date=22%2F12%2F2015 and it works as expected.
The 'date' parameter is formatted as a string such as 22/12/2015 'dd/M/yyyy'
Any suggestions? Thank you!