答案 0 :(得分:5)
它没有保存。它使用Contact name字符串的哈希码来确定颜色。
示例:
String name = "Harish";
int colors[] = new int[] { Color.RED, Color.GREEN, Color.BLUE};
int chosenColor = colors[Math.abs(name.hashCode()) % colors.length];
我从这个answer
中学到了什么答案 1 :(得分:1)
您可以试试像这样的颜色生成器..
protected void Application_Error(object sender, EventArgs e)
{
var lastException = Server.GetLastError();
var wrappedContext = new HttpContextWrapper(Context);
wrappedContext.Response.StatusCode = (lastException as HttpException)?.GetHttpCode() ?? 500;
wrappedContext.Response.Clear();
wrappedContext.Response.TrySkipIisCustomErrors = true;
wrappedContext.Server.ClearError();
var routeData = new RouteData();
routeData.Values.Add("area", "");
routeData.Values.Add("controller", "Error");
routeData.Values.Add("action", "Index");
routeData.Values.Add("httpResponseCode", Context.Response.StatusCode);
IController errorController = DependencyResolver.Current.GetService<ErrorController>();
errorController.Execute(new RequestContext(wrappedContext, routeData));
}