Ser*_*gio 6 asp.net-mvc internet-explorer
奇怪的事情发生在这里.
我有一些JS发布到ASP.NET MVC ActionMethod,它可以在除IE的任何版本之外的每个浏览器中查找.有问题的代码如下:
$.ajax({
url: path,
type: 'POST',
data: { team: team_copy[team_copy.length - 1], queryDate: d.toUTCString(), newOutlets: newOutlets },
success: function (MyResponseObject) {
holder.append(MyResponseObject.content);
//locate active section and click to show new content - its a mess, but it works
//activeMenu.click();
MessageSystem.showMessage("Target Data System", MyResponseObject.message, false);
if (team_copy.length > 1) {
team_copy.pop();
$('#actualprogress').animate({ width: '+=' + TargetReports.progressratio + '%' }, 'slow');
TargetReports.getTeamData(team_copy, d, newOutlets);
}
else {
MessageSystem.showMessage("Complete", "All Data Fetched", false);
$('#show-calendar-selection').fadeIn();
TargetReports.buildTotalsTable("daysandcalls", "daysandcallstotal");
TargetReports.buildTotalsTable("volumeanddistribution", "volumeanddistributiontotal");
TargetReports.buildTotalsTable("outletactivation", "outletactivationtotal");
TargetReports.buildTotalsTable("promotion", "promotiontotal");
//$('#progress').fadeOut().remove();
$('#results-options').fadeIn();
$('#total-holder').fadeIn();
activeMenu.click();
//update link to download file
var hidden = $('.hidden-information').first();
var newOutlets = encodeURIComponent($('input[name="newoutlets"]', hidden).val());
var queryDate = encodeURIComponent($('input[name="enddate"]', hidden).val());
var anchor = $('#get-target-reports');
var link = anchor.attr('href');
link = "/manager/TargetResults.csv?endDate=" + queryDate + "&newOutlets=" + newOutlets;
anchor.attr('href', link);
}
}
});
Run Code Online (Sandbox Code Playgroud)
Action Method签名如下所示:
public ActionResult GenerateTargetData(int team, DateTime queryDate, bool forceRegen = false, bool newOutlets = false)
Run Code Online (Sandbox Code Playgroud)
在IE .NET中运行时,会抱怨queryDate参数的空条目.使用IE中的调试工具我可以看到请求体看起来如下:
team=7&queryDate=Mon%2C+29+Nov+2010+23%3A15%3A39+UTC&newOutlets=false
Run Code Online (Sandbox Code Playgroud)
在Firefox中,它有效:
team=7&queryDate=Mon%2C+29+Nov+2010+23%3A10%3A46+UTC&newOutlets=false
Run Code Online (Sandbox Code Playgroud)
我真的不知道这里有什么.所有帮助赞赏!
您的问题似乎是因为ASP.net MVC模型绑定器将接受ISO8601格式的日期时间.
如果时间是UTC,则在没有空格的时间之后直接添加"Z".'Z'是零UTC偏移的区域指示符.因此,"09:30 UTC"表示为"09:30Z"或"0930Z"."14:45:15 UTC"将是"14:45:15Z"或"144515Z".
我已经检查过chrome 12.0.733.0 dev,Firefox 4,IE 9.如果你调用javascript toUTCString(),不同的浏览器返回不同的东西.Chrome和Firefox将返回"Wed,20 Apr 2011 20:31:11 GMT ",只有IE返回"Wed,2011年4月20日20:31:11 UTC "
d.toUTCString().replace('UTC','Z')对你有用.