在将应用程序发布到IIS时,如何在MVC中将datetime与格式dd / mm / yyy绑定?(How to bind datetime with format dd/mm/yyy in MVC

系统教程 行业动态 更新时间:2024-06-14 17:02:17
在将应用程序发布到IIS时,如何在MVC中将datetime与格式dd / mm / yyy绑定?(How to bind datetime with format dd/mm/yyy in MVC when publish Application to IIS ?)

真的,我的问题很简单,但我不知道如何解决它。 我有一个ActionResult方法,返回View并采取datetime属性,所以我发送这样的ActionLink datetime属性

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

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

really my problem is simple but i don't know how to solve it. i have an ActionResult method that return View and take datetime attribute so i send datetime attribute in ActionLink like this

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

the ImpDate.DateConfig is the date that i sent to Action when i run in local mode the datetime binded with this format dd/MM/YYY there is no problem till now the problem comes when i publish it in IIS the datetime binded with this format MM/DD/YYY and this make problem to me can any one know why it binded in a different way ?

最满意答案

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

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

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

Convert the date object to string format you want:

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

The ActionLink helper will be automatically url encode the route data.

更多推荐

本文发布于:2023-04-21 18:35:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/5467e56ed0d0740ea7e88a87873a78b9.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:绑定   中将   应用程序   格式   如何在

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!