Tag Archives: ASP.NET

Full Text Search with ASP.NET MVC, jQuery autocomplete and Elasticsearch

This article demonstrates how to do a full text search using jQuery Autocomplete with an ASP.NET MVC application and an Elasticsearch search engine. CRUD operations are also implemented for Elasticsearch ( ElasticsearchCRUD ). To download and install Elasticsearch, use the instructions here. Code: https://github.com/damienbod/WebSearchWithElasticsearch Other tutorials: Part 1: ElasticsearchCRUD introduction Part 2: MVC application search […]

Exploring Web API Exception Handling

In this article, exception handling is explored for Web API. The standard features from Web API 2 are shown as well as the global exception handling released in version 2.1. code: https://github.com/damienbod/WebApi2_1ExceptionHandling Using the HttpResponseException class The following two examples demonstrates how the HttpResponseException class can be used in simple action methods. The HttpStatusCode enum […]

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 […]

AOP with ASP.NET Web Api

This blog demonstrates the usage of filters and unity interface interception with an ASP.NET Web Api application. AOP = Aspect oriented programming. This programming paradigm can be used to add functionality to existing methods. In the following example, we wrap the controller method with diagnosis using filters and then we wrap the business manager with […]

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 […]

MVC Async File Upload

To use the upload html control inside an ajax request, the following steps need to be taken: Define an ajax function for the upload button Define the form for the upload Add the input file control to the form Handle the file in the MVC controller Return the json result, wrapped in a text item […]

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 […]