0
  • WebForms, .NET 4.61

I am having an issue where dates are not converting from strings.

public dsBookingActual GetBookingActualData(Int64 ozBookingID, string consultant, string screenViewed)
{
            DbCommand dbCommand = db.GetStoredProcCommand("usp_GetBookingActualData");
            db.AddInParameter(dbCommand, "@OzBookingID", DbType.Int64, ozBookingID);
            db.AddInParameter(dbCommand, "@Consultant", DbType.String, consultant);
            db.AddInParameter(dbCommand, "@ScreenViewed", DbType.String, screenViewed);

            dsBookingActual dsBA = new dsBookingActual();
            //LoadDataSet fails when the date is 29/01/2016
            db.LoadDataSet(dbCommand, dsBA, new string[] { Constant.BOOKING_ACTUAL, "Passengers" });
            return dsBA;
}

We are in AU so the date format is dd/mm/yyyy and converting dates of 29/01/2016 fail as it is being attempted as mm/dd/yyyy for instance and 29 is not a valid month.

I tracked it down to the fact that the language settings in the browser are set to US similair to this post.

We have a globailzation tag in system.web as:

<globalization culture="en-AU" requestEncoding="utf-8" responseEncoding="utf-8" uiCulture="en-AU" />

So my question is how do I prevent the culture changing across the request. I am guessing it involves not acknowledging or processing the "Accept-Language header in the HTTP Request" but I am unsure how to implement this.

Any pointers appreciated.

1
  • "I am having an issue where dates are not converting from strings" can you show the code where this happen?
    – Ian
    Feb 22, 2016 at 3:31

1 Answer 1

0

As it turns out this issue was as a consequence of our usage of ASP Boilerplate. Nothing wrong with the framework, it was our usage of it that was causing the issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.