我搜索了这个主题,我遇到了三种不同的方式来配置浏览器功能:browscap.ini,web.config中的browserCaps元素和App_Browsers中的.browser文件.我认为.browser文件是最新的方式,但我似乎没有找到最新的文件.但是我从http://browsers.garykeith.com/downloads.asp找到了相当新鲜的browscap.ini .
我的首要任务是从访问者统计信息中排除常见的抓取工具.第二个优先级是检测具有正确版本的浏览器和操作系统(例如Opera 11/Win7).
我可以使用任何库吗?browscap.ini仍然是一种有效的方式,是否可以在不访问系统文件的情况下使用它?我在哪里可以找到最新的.browser文件?
如果我有一个约定来更改编辑器并设置一些值
public class MetadataProvider : DataAnnotationsModelMetadataProvider
{
protected override ModelMetadata GetMetadataForProperty(Func<object> modelAccessor, Type containerType, System.ComponentModel.PropertyDescriptor propertyDescriptor)
{
var meta = base.GetMetadataForProperty(modelAccessor, containerType, propertyDescriptor);
if (IsNumericType(propertyDescriptor.PropertyType))
{
meta.TemplateHint = "Number";
var attr = propertyDescriptor.Attributes.OfType<RangeAttribute>().FirstOrDefault();
if (attr != null)
{
meta.AdditionalValues["min"] = attr.Minimum;
meta.AdditionalValues["max"] = attr.Maximum;
}
}
return meta;
}
//...
}
Run Code Online (Sandbox Code Playgroud)
然后我可以在模板中获取其他值
@{
var min = ViewData.ModelMetadata.AdditionalValues["min"];
var max = ViewData.ModelMetadata.AdditionalValues["max"];
}
Run Code Online (Sandbox Code Playgroud)
但是,如果我使用相同的模板
@Html.EditorFor(x => x.Number, new { min = 1, max = 10 })
Run Code Online (Sandbox Code Playgroud)
然后我应该得到这样的价值观
@{
var min = …Run Code Online (Sandbox Code Playgroud) 我有课
[MongoDiscriminated]
public abstract class Content
{
public int? Id { get; set; }
public int? ParentId { get; set; }
public string Slug { get; set; }
public string Path { get; set; }
public string Title { get; set; }
}
public class Area : Content
{
}
Run Code Online (Sandbox Code Playgroud)
像这样的查询有效
var item = mongo.GetCollection<Area>().AsQueryable().FirstOrDefault();
Run Code Online (Sandbox Code Playgroud)
但是当我提出类似的查询时
var item = mongo.GetCollection<Content>().AsQueryable().FirstOrDefault();
Run Code Online (Sandbox Code Playgroud)
我得到一个InvalidCastException
Object must implement IConvertible.
Run Code Online (Sandbox Code Playgroud)
怎么了?将Area转换为Content应该不是问题.我真的必须制作内容才能实现IConvertible吗?
有没有办法在C之前强制绑定属性A和B?
System.ComponentModel.DataAnnotations.DisplayAttribute类中有Order属性,但它是否会影响绑定顺序?
我想要实现的是
page.Path = page.Parent.Path + "/" + page.Slug
Run Code Online (Sandbox Code Playgroud)
在自定义的ModelBinder中