ASP.NET Application is displaying american date formats

后端 未结 2 814
长情又很酷
长情又很酷 2021-01-22 04:56

One of my development applications has today started displaying American formatted short dates where I am expecting British formatting.

The dates are being rend

2条回答
  •  长情又很酷
    2021-01-22 05:20

    The windows regional settings does not affect any website, unless the website is programmed to get the regional settings from the browser preferred languages and apply them to the ASP site

    Use the globalization option in the web.config

    
    

    OR

    Set the value in the global.aspx Application_BeginRequest method

    Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
        Dim lang As String = "es"
        If HttpContext.Current.Request.Path.Contains("/en/") Then
            lang = "en"
        ElseIf HttpContext.Current.Request.Path.Contains("/pt/") Then
            lang = "pt"
        ElseIf HttpContext.Current.Request.Path.Contains("/es/") Then
            lang = "es"
        End If
        Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(lang)
        Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(lang)
    End Sub
    

提交回复
热议问题