如何使用ASP.NET 5禁用客户端验证? 我尝试在config.json中将ClientValidationEnabled设置为false,如here,但我仍然在html元素中有data-val- *属性. 答案: services.AddMvc() .ConfigureMvcViews(options = { options.Ht
我尝试在config.json中将ClientValidationEnabled设置为false,如here,但我仍然在html元素中有data-val- *属性.
答案:
services.AddMvc() .ConfigureMvcViews(options => { options.HtmlHelperOptions.ClientValidationEnabled = false; });我不认为在ASP.NET 5中支持通过AppSettings进行配置.一个选项是在Startup类的ConfigureServices方法中以编程方式配置它:
public void ConfigureServices(IServiceCollection services) { services .AddMvc() .AddViewOptions(options => { options.HtmlHelperOptions.ClientValidationEnabled = false; }); }
ClientValidationEnabled已移至MvcViewOptions上的HtmlHelperOptions属性.