When try to save data to database with db_ent.SaveChanges()
I have this error:
Culture 'sr' is a neutral culture. It cannot be used in formatting and parsing and therefore cannot be set as the thread's current culture. Any solutions for this?
Edit:
My RouteLocalization Helper
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using System.Threading;
using System.Globalization;
namespace darns.Helpers
{
public class MultiCultureMvcRouteHandler : MvcRouteHandler
{
protected override IHttpHandler GetHttpHandler(System.Web.Routing.RequestContext requestContext)
{
String culture = requestContext.RouteData.Values["culture"].ToString();
var ci = new CultureInfo(culture);
Thread.CurrentThread.CurrentUICulture = ci;
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(ci.Name);
return base.GetHttpHandler(requestContext);
}
}
public class SingleCultureMvcRouteHandler : MvcRouteHandler {}
public class CultureConstraint : IRouteConstraint
{
private string[] _values;
public CultureConstraint(params string[] values)
{
this._values = values;
}
public bool Match(HttpContextBase httpContext,Route route,string parameterName,
RouteValueDictionary values, RouteDirection routeDirection)
{
// Get the value called "parameterName" from the
// RouteValueDictionary called "value"
string value = values[parameterName].ToString();
// Return true is the list of allowed values contains
// this value.
return _values.Contains(value);
}
}
public enum Culture
{
sr = 1,
hr = 2,
en = 3,
ru = 4
}
/// <summary>
/// Util class for storing error message pairs
/// </summary>
/// <typeparam name="E"></typeparam>
/// <typeparam name="T"></typeparam>
public class ErrorPair<E, T>
{
public E Key { get; set; }
public T Message { get; set; }
public ErrorPair(E key, T message)
{
Key = key;
Message = message;
}
}
}