在将应用程序发布到IIS时,如何在MVC中将datetime与格式dd / mm / yyy绑定?

时间:2016-09-20 11:26:32

标签: asp.net-mvc datetime iis publish

真的我的问题很简单,但我不知道如何解决它。  我有ActionResult方法,返回View并获取datetime属性,因此我在datetime中发送ActionLink属性

@Html.ActionLink("ForignSell", "ForignSell", "Reports", new  {Start =@ImpDate.DateConfig},null)

ImpDate.DateConfig是我在本地模式下运行时发送到Action的日期datetime以此格式绑定dd/MM/YYY直到现在问题都没有问题当我在 IIS 中发布datetime这个格式为MM/DD/YYY的{​​{1}}时出现问题,这对我来说有问题,任何人都可以知道为什么它以不同方式绑定了吗?

1 个答案:

答案 0 :(得分:0)

将日期对象转换为您想要的字符串格式:

@Html.ActionLink("ForignSell", "ForignSell", "Reports", new  {Start = @ImpDate.DateConfig.ToString("dd/MM/yyy")}, null)

ActionLink助手将自动对路径数据进行url编码。