Tag Archives: asp.net-mvc

NodeJS architecture based on ASP.NET MVC

The project for this post can be found at my GitHub. I’m using the following packages:

  • express: helps you setup your application to handle requests.
  • express-handlebars: this allows you to send data from the server to your views, you can think of it as the razor for node.

.NET MVC works by making requests map to controllers and actions. The same can be achieved in node.
Continue reading

Advertisements

Nuget Package: ValueInjecter

ValueInjecter is a nuget package that allows you to inject values from one object to another.

ValueInjecter lets you define your own convention-based matching algorithms (ValueInjections) in order to match up (inject) source values to destination values. It is used for mapping Dto to Entity and back also for mapping IDataReader to objects, windows forms to object, basically anything. Also has support for flattening and unflattening.

One good use for ValueInjecter is when you are working with models and viewmodels. With it you can build models from viewmodels and viewmodels from models.
Continue reading

The async and await in ASP.NET MVC

The async and await combination allows you to have non-blocking methods.

In ASP.NET MVC you can have asynchronous actions. It might sound a good idea to make all your actions async, but it is not. Light operations like returning a view, handling a post, will likely get slower because the cost of creating a thread will be much higher.

But you can benefit from it by using it against I/O operations.
Continue reading

Understanding ASP.NET MVC fundamentals

In a standard ASP.NET project with MVC you have a basic structure which is the separation of the Models / Views / Controllers.

In the Views folder you have two key files, the _ViewStart.cshtml special file which is where the views start up. By default it defines the shared layout all the views are going to use, which leads us to the second key file Shared\_Layout.cshtml. This file is the base site layout (if you know Web Forms you can think of it as a Master Page). Your views are going to be rendered inside this base view where it calls @RenderBody() which is going to render your view.
Continue reading

View validation with Data Annotations and custom client validations in MVC

In the post Using Data Annotations to validate models I showed that it is possible to keep validations in attributes.

In this post I am going to show how to apply these validations on the client-side.

By default when you create a standard MVC project it creates all initial structure for you, including the setup of the scripts. To enable client-side validation you need two keys under appSettings in your web.config file (which are set by default in the standard template):
Continue reading