views:

19

answers:

2

I have the following code. dateStart & dateEnd are both DateTime. My issue is that this is generating the following url

https://www.mysite.localhost/Order/Products/27?categoryId=0&dateStart=09%2F24%2F2010%2000%3A00%3A00&dateEnd=10%2F01%2F2010%2000%3A00%3A00&allDates=0

the issue is that it's creating 09/24/2010 and not 24/09/2010

var url = Url.Action("Products", "Order",
                                     new
                                         {
                                             id = companyId,
                                             categoryId = 0,
                                             dateStart = dateStart,
                                             dateEnd = dateEnd,
                                             allDates = 0
                                         });
A: 

The issue you are running into is culture related. check out this msdn article for more info:
http://msdn.microsoft.com/en-us/library/5hh873ya.aspx

Joel Martinez
A: 

try one of this

•Set the culture and user interface culture in Web.configUse this approach if you want to set the default culture and user interface culture for all the pages in a Web application. The following fragment from a Web.config file illustrates this technique.

< configuration>

< system.web> < globalization culture="en-US" uiCulture="de-DE" />

< /configuration>

•Set the culture and user interface culture in the @ Page directiveUse this approach if you want to override the default culture and user interface culture for a specific page in a Web application. The following fragment from an .aspx file illustrates this technique.

<%@ Page Culture="en-GB" UICulture="Fr-FR" %>

•Set the culture and user interface culture programmaticallyUse this approach if you want to select which culture and user interface culture to use at run time. Note You cannot change a thread's culture in semi-trusted code; changing the culture requires a SecurityPermission with the SecurityPermissionFlag,ControlThread set. Manipulating threads is dangerous because of the security state associated with threads. Therefore, this permission should be given only to trustworthy code, and then only as necessary. The following code in an ASP.NET Web page retrieves the user's language preferences from the Request.UserLanguages property and uses the culture and user interface culture for the preferred language.

using System.Globalization; using System.Threading;

// Set the culture to the browser's accept language Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(Request.UserLanguages[0]);

// Set the user interface culture to the browser's accept language Thread.CurrentThread.CurrentUICulture = new CultureInfo(Request.UserLanguages[0]); Note You cannot change the CurrentCulture or CurrentUICulture properties when programming with the .NET Compact Framework. If you have to support per-application localization on smart-client devices such as Pocket PCs, you must use a CultureInfo object to store the user-selected culture internally, and use it explicitly whenever loading resource files or formatting data.

i've copied from http://msdn.microsoft.com/en-us/library/ff647353.aspx

Hasu