Category Validation

Require user password verification with ASP.NET Core Identity to access Razor Page

This post shows how an ASP.NET Core application which uses ASP.NET Core Identity to authenticate and authorize users of the application can be used to require user password verification to view specific Razor pages in the application. If the user opens one of the Razor pages which require a password verification to open the page, […]

An alternative way to build and bundle Javascript, CSS in ASP.NET Core MVC and Razor Page projects

This article shows how Javascript packages, files, CSS files could be built and bundled in an ASP.NET Core MVC or Razor Page application. The Javascript packages are loaded using npm in which most Javascript projects are deployed. No CDNs are used, only local files so that all external URLs, non self URL links can be […]

ASP.NET Core Action Arguments Validation using an ActionFilter

This article shows how to use an ActionFilter to validate the model from a HTTP POST request in an ASP.NET Core MVC application. Code: https://github.com/damienbod/AngularAutoSaveCommands History 2021-01-20: Updated to ASP.NET Core 5, Angular CLI 11.0.9 2019-07-31: Updated to ASP.NET Core 3.0 Preview 7, Updated to Angular 8.1.3 2019-02-16: Updated to Angular 7.2.4, ASP.NET Core 2.2 […]

Multiple ViewModels in a single MVC View

This post shows how to use multiple models in a single view. The models can be used in separated forms or together in one form. You could use each child model with a separate ajax post if required. Only properties in the parent class affect the child models, but a property in a child model […]

Turning off validation for properties in a MVC model

Sometimes it is required that some properties in a MVC model should not be validated, but the rest are required and should be validated in the client view. Mostly I cannot turn off client validation for all properties in the model. Here is an example of a Model class. I need to validate 2 properties […]

Validation in MVC, Enterprise Library, Fluent Validation, Data Annotations, FoolProof

MVC Validation MVC has many possibilities for validation. Depending on the use case, the correct validation should be used. Here is a list of MVC validation possibilities: Server side Model-level validation Server side Property-level validation Client side Model-level validation Server side Property-level validation Server side custom validation When validating, a number of problems can exist […]

Simple MVC Application using FluentValidation.MVC4

This is a simple example of MVC application using FluentValidation.MVC4. http://fluentvalidation.codeplex.com/ Create a new web application MVC4. Get the fluent validation using nuget: Create a validation rule set class: Now add the attribute to the model class: FluentDataModel Add the Provider to the Global.asax file App_Start() method And the validation works (Note: the dependency validation […]

Simple MVC Application using standard Validation (DataAnnotations)

This is a simple example of standard MVC validation provided in the .NET framework. Create a new MVC application. Edit the index.cshtml file. Important: for client validation to work, the scripts section must be included. (Defined per default in the _Layout View and the BundleConfig.cs in the App_Start folder) Create a Model Edit the web.config […]

Simple MVC Application using Enterprise Library Validation

This is an example of a simple MVC application using Enterprise Library validation First add the EL validation to your project using nuget: Now the Enterprise Library Validation has to be added to the ModelValidatorProviders Create a EnterpriseLibraryValidatorWrapper class And now create a EnterpriseLibraryValidatorProvider Now add it to the Application_Start() method in the global.asax The […]