Tags Custom ModelBinder

In this post we are going to create a custom model binder in ASP.NET Core MVC that converts CSV text into IEnumerable of strings automatically. Model In MVC a model is where data is being kept while going from controller to view and comming back. In ASP.NET MVC since we are using C# a Model is actually a class with some properties. Model Binder A model binder’s job is to map(bind) content in HTTP request to the models.

PartialView vs TagHelper : A Performance Comparison

TagHelper is a new feature in ASP.NET Core. We usually use TagHelpers to generate HTML like tags and compared to the old HtmlHelpers, TagHelpers are a much cleaner approach. In many cases we can use TagHelpers to replace PartialViews too. of course developing TagHelpers are a lot more difficult and need to put on more time. In this experiment I try to compare using PartialViews vs TagHelpers performance wise. I’m not sure if this is a totally legitimate way to compare in theory, But in practice the code here is what web developer use in a daily basis.

Injecting LiteDb as a service in ASP.NET Core

Intoduction LiteDB is a simple, fast and lightweight embedded .NET document database. LiteDB was inspired by the MongoDB database and its API is very similar to MongoDB’s official .NET API. Situation I have been using LiteDb for some of my smaller projects and I’ve got to tell you that so far it has beed satisfying. But my problem was injecting LiteDb as a service inside ASP.NET Core applications. Usually in ASP.

How to work with Action Filters in ASP Core

Every time you need to store some data in database you have to validate it first. we usually need to create an if/else block and make sure ModelState is valid and send back some error messages if it’s not. ActionFilters are a great way to implement the DRY principle. Here we are going to create a simple ActionFilter to do the Model Validation before getting into the Action. The code goes like this :

About

Hi, My name is Hakim Ghods and I've been a .NET developer for almost 10 years. In this blog I'm sharing my experience working with ASP.NET Core. Links GitHub LinkedIn YouTube Website Email : ghods.hakim@hotmail.com

Configurations in ASP.NET Core 2.0

With new version of ASP.NET Core configuration system has changed a lot. First it is now inject able into the framework. then you can add custom options to the base Configuration class and access it anywhere needed. In this post I’m going to list all available configurations in ASP.NET Core 2.0 . and to do that I started by injecting configuration using a constructor. public class Startup { public IConfiguration Configuration { get; } public Startup(IConfiguration config) { Configuration=config; } } From now on we can use Configuration anywhere in the Startup class.

Error Handling With ASP.NET Core

Error handling is real and it’s serious. In ASP.NET Core it’s much more easier to handle errors. in this post I’m digging into error handling and trying to get some errors ! Middlewares Like many other features in ASP.NET Core, Error handling is done through Middlewares, there is UseDeveloperExceptionPage() and UseExceptionHandler() to start with. The first one is used to show detailed error information for developers and the second is to redirect users to error page when something goes wrong.

A Vuejs CRUD Project With ASP NET Core

I enjoy working with Vue.js. It’s just a good SPA framework, it has everything I like about a javaScript framework. Today I created a sample project with Vue.js and ASP.NET Core MVC 2.0 that has all CRUD operations. I want to share the code here. Project BugVue This is a simple app for tracking bugs. You can Create, Read, Update and Delete the in UI and it all happens in the same view thanks to Vue.

Exploring in Line Middlewares

In-line middlewares are a simple way to add functionality to ASP.NET Core pipeline without going through a ceremony. In this post I’m playing with app.Run and app.Use and see how these two work. Simplest middleware possible The best way to understand how a middleware works is to remove the noise around it. so, this is the simplest middleware you can build in ASP.NET Core 2.0. app.Run(async (context) => { await context.

How to Create Middleware in ASP Core

One of the best features of ASP.NET Core is it’s flexible pipeline. You can control what goes into your application’s pipeline and add more to it using a Middleware. SendFile Middleware This middleware is just a sample project to see how middlewares are created in ASP.NET Core. I tried to keep it is simple as possible,after all this is my first middleware. What it does? You set a file path at startup and SendFile Middleware sends the file back to user in browser.

Bare Minimum Hello World

In this post I’m exploring what is the bare minimum necessary code to show “Hello World!” in an ASP.NET Core 2.0 Application. bear with me! The template To get the bare minimum in the first place you need to create a project using “ASP.NET Core Empty” template. Program.cs The most important part that you have to change here is the CreateDefaultBuilder Method.There are so many parts that you don’t need, Like settings a Logging.

First 3 Days With ASP Core 20

About 3 days ago the final version of ASP Core 2.0 released. I installed the new bits and have been playing with it since. here is my experience so far. Fantastic. No bugs So far I experienced no bugs. Everything works perfectly. No compatibility issues like the previews version and no errors. Its fast and reliable. .Net Standard 2.0 Its really the best part of the new version. it feels more matured than the last version.