This method is used to auto-generate some Html fields to reduce code duplication. It works perfectly fine when I host it locally:
static string GenerateTextField<DBType, FieldType>(this HtmlHelper<DBType>
page, Expression<Func<DBType, FieldType>> fieldExp, string formControlData)
{
var model = page.ViewData.Model;
var fieldName =
ExpressionHelper.GetExpressionText(fieldExp).Split('.').Last();
var formatRules = new CultureInfo("en-EN");
string valueText = "";
var value = model != null?
fieldExp.Compile()(model):
default(FieldType);
if (typeof(FieldType).IsAssignableFrom(typeof(float))) valueText =
((float)(object)value).ToString(formatRules);
else valueText = value?.ToString();
System.Diagnostics.Debug.WriteLine("valueText =" + valueText);
return [html text, converted to MvcHtmlString elsewhere];
}
However, when I export it to be hosted by Azure web app and run it there, it announces: Culture is not supported. Parameter name: name en-EN is an invalid culture identifier.
I am aware of the topic Culture is suddenly not supported anymore on Azure web app. The problem is that the remedy suggested there concetrates on how to build a RegionInfo, which I'm not even using.
I need that formatting with english culture because the html field uses a custom numeric spinner which tructates the database value if it is entered with a decimal comma instead of a decimal point.
I can of course format the string by hand, but is there a better solution?