Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configuring Azure web and SQL UK Culture

I've recently moved a classic asp site which uses SQL Server to Azure Shared websites, with SQLAzure as the database.

Its region is north Europe (Ireland).

I need the database to be running under en-GB locale and as such dates returned from SQL to be in the format DD/MM/YYYY and the same in IIS. However they are currently being returned using MM/DD/YYYY US format.

I've tried adding the below to the web.config:

<globalization culture="en-GB"
       uiCulture="en-GB" /> 

but I still get a US dateformat when I add the following to the page.

<% response.write(now()) %>

i.e.

2/10/2015 11:32:13 AM.

Additionally I cannot see where in the portal or via SQL Server Management Studio I can change the user setting to be GB locale. As I can see that dates returned from SQL are also US date format.

Unless I'm missing something this surely must be common issue for UK Azure customers but I cannot find any resources to solutions to this problem.

like image 492
Tim Avatar asked Mar 18 '23 02:03

Tim


1 Answers

Ok so to fix the "Classic Asp" side. Adding a global.asa with the following contents seems to fix it for the English-GB Locale

<script language="vbscript" runat="server">

    sub Session_OnStart
    'some code
         Session.LCID = 2057
    end sub
</script>

For a MVC5 application with a similar problem I read that the below should work

 <configuration>
    <system.web>
        <globalization uiCulture="en-GB" culture="en-GB" />
    </system.web>
 </configuration>

However in Azure i couldn't resolve an internal server error using this method.
But I did successfully implement the below in the Global.asax which correctly renders the en-GB date format:

protected void Application_PreRequestHandlerExecute(object sender, EventArgs e)
   {
    Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-GB");
   }
like image 189
Tim Avatar answered Mar 29 '23 18:03

Tim