Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable Client Side Validation with ASP.NET 5

How to disable Client Side Validation with ASP.NET 5?

I tried to set ClientValidationEnabled to false in config.json like here but I still have data-val-* attributes in html elements.

Answer :

services.AddMvc()
        .ConfigureMvcViews(options =>
        {
           options.HtmlHelperOptions.ClientValidationEnabled = false;
        });
like image 945
Steven Muhr Avatar asked Aug 24 '15 22:08

Steven Muhr


1 Answers

I don't believe configuring this via AppSettings is supported out of the box in ASP.NET 5. One option is to programmatically configure this in your Startup class's ConfigureServices method:

    public void ConfigureServices(IServiceCollection services)
    {
        services
            .AddMvc()
            .AddViewOptions(options =>
            {
                options.HtmlHelperOptions.ClientValidationEnabled = false;
            });

    }

The ClientValidationEnabled was moved to an HtmlHelperOptions property on MvcViewOptions.

like image 70
Peter Avatar answered Sep 22 '22 05:09

Peter