Posts tagged "C#"

Published:

Blazor WebAssembly - Form Validation Example

This is a quick example of how to setup form validation in ASP.NET Core Blazor WebAssembly. The example is a simple registration form with pretty standard fields for title, first name, last name, date of birth, email, password, confirm password and an accept terms and conditions checkbox.
Published:

ASP.NET Core Blazor WebAssembly - Communication Between Components

This is a quick tutorial to show how you can send messages between components in a Blazor WebAssembly (WASM) application.
Published:

ASP.NET Core 3.1 - Create and Validate JWT Tokens + Use Custom JWT Middleware

This is a quick example of how to create and validate JWT tokens in ASP.NET Core 3.1. We also cover how to implement custom JWT authentication with custom JWT middleware and a custom authorize attribute.
Published:

ASP.NET Core 3.1 - Hash and Verify Passwords with BCrypt

A quick example of how to hash and verify passwords ASP.NET Core 3.1 using the BCrypt.Net-Next password hashing library which is a C# implementation of the bcrypt password hashing function.
Published:

ASP.NET Core 3.1 - Send Emails via SMTP with MailKit

This is a quick example of how to send an email in ASP.NET Core 3.1 using the MailKit email client library.
Published:
Last updated:

ASP.NET Core 3.1 - Boilerplate API with Email Sign Up, Verification, Authentication & Forgot Password

How to build a boilerplate authentication API with ASP.NET Core 3.1 that includes email sign up & verification, authentication & role based authorization, forgot password & reset password functionality, account management (CRUD) routes with role based access control, and Swagger documentation.
Published:

ASP.NET Core - Setup Development Environment

A quick post to show how to setup an ASP.NET Core development machine.
Published:

ASP.NET Core 3.1 API - JWT Authentication with Refresh Tokens

How to implement JWT authentication with refresh tokens in an ASP.NET Core 3.1 API. Includes example client app built with Angular.
Published:

ASP.NET Core API - Allow CORS requests from any origin and with credentials

This is a quick post to show how to configure an ASP.NET Core API to allow CORS requests from any origin as well as with credentials.
Published:
Last updated:

ASP.NET Core - EF Core Migrations for Multiple Databases (SQLite and SQL Server)

An example of how to setup an ASP.NET Core project with EF Core Migrations that support multiple different database providers.
Published:

ASP.NET Core - Automatic EF Core Migrations to SQL Database on Startup

This is a super quick example of how to automatically migrate database changes from code in ASP.NET Core using Entity Framework Core from the Startup.cs file.
Published:
Last updated:

ASP.NET Core 3.1 - Basic Authentication Tutorial with Example API

How to implement Basic HTTP Authentication in ASP.NET Core 3.1 with C#. Includes example client apps built with Angular, React and Vue.js.
Published:
Last updated:

ASP.NET Core 3.1 - Role Based Authorization Tutorial with Example API

How to build an API with role based authorization / access control in ASP.NET Core 3.1 & C#. Includes example client apps built with Angular, React and Vue.
Published:
Last updated:

ASP.NET Core 3.1 - Simple API for Authentication, Registration and User Management

Simple boilerplate ASP.NET Core 3.1 API that supports User Registration, Login and User Management. Uses SQLite in development & SQL Server in production and includes example client apps built with React, Angular & Vue.
Published:
Last updated:

ASP.NET Core 3.1 - JWT Authentication Tutorial with Example API

How to implement custom JWT authentication in ASP.NET Core 3.1 with C#. Includes example client apps built with React, Angular & Vue.
Published:

ASP.NET Core 2.2 - Role Based Authorization Tutorial with Example API

How to build an API with role based authorization / access control in ASP.NET Core 2.2 & C#. Includes example client apps built with Angular, React and Vue.
Published:

C# - Pure Pagination Logic in C# / ASP.NET

Pure pagination logic written in C# / ASP.NET and available on NuGet. Compatible with ASP.NET Core and ASP.NET Standard projects.
Published:

ASP.NET Core Razor Pages - Pagination Example

An example of how to add pagination to your ASP.NET Core 2.1 Razor Pages application.
Published:
Last updated:

ASP.NET Core 2.2 - Basic Authentication Tutorial with Example API

How to implement Basic HTTP Authentication in ASP.NET Core 2.2 with C#. Includes example client apps built with Angular, React and Vue.js.
Published:
Last updated:

ASP.NET Core 2.2 - JWT Authentication Tutorial with Example API

How to implement JWT authentication in ASP.NET Core 2.2 with C#. Includes example client apps built with React, Angular & Vue.
Published:
Last updated:

ASP.NET Core 2.2 - Simple API for Authentication, Registration and User Management

A clean and simple custom ASP.NET Core API for User Registration, Login with JWT Authentication and User Management.
Published:

C# / ASP.NET - Domain Validation Logic in Domain Driven Design (DDD)

An example showing how and where to implement Domain Model Validation in C# and ASP.NET projects using Domain Driven Design (DDD)
Published:

ASP.NET MVC - Pagination Example with Logic like Google

An example of how to setup Google style pagination logic in C# and ASP.NET MVC.
Published:

Fluent NHibernate - Unproxy Entity Objects with AutoMapper

How to unproxy NHibernate objects to get real entity objects instead of NHibernate proxied classes.
Published:

C# - Incremental Delay to Prevent Brute Force or Dictionary Attack

An example of how to implement an incremental delay in C# to prevent brute force or dictionary attacks on an MVC login form.
Published:

Dynamic LINQ - Using strings to sort by properties and child object properties

I stumbled across the Dynamic LINQ Library today and can't figure out why more people aren't talking about it. It's an awesome little library that allows you to dynamically generate LINQ expressions from strings, which is perfect for things like sorting collections by object property names passed as querystring parameters to web api controllers, it even allows you to sort by child object property names!
Published:

Web API 2 + ELMAH - Log ALL Unhandled Exceptions

I got an email from a client today about an error happening in an application that I'd built with ASP.NET Web API 2.1. At first I thought they must be mistaken or doing something wrong on their end because their weren't any errors being reported by ELMAH which I'd configured in my WebApiConfig.cs file using the ElmahHandleErrorApiAttribute filter.
Published:

Moq - Get Setup() to return a dynamic collection from a fake repository

Read on if you're confused about why your mock repository keeps returning the initial collection even though you've added something to it!
Published:

Post a simple string value from AngularJS to .NET Web API

How to post a simple string parameter in the body of an HTTP request from AngularJS to ASP.NET Web API
Published:

ASP.NET Web API 2 - Enum Authorize Attribute

This post shows you how to create a custom authorization attribute which allows you to pass in a list of enums as parameters to restrict access by role. I'm using this attribute on the controllers of a RESTful Web API built with ASP.NET WEB API 2.
Published:
Last updated:

ASP.NET MVC - Required Checkbox with Data Annotations

How to make a required checkbox in ASP.NET MVC using the built in 'Range' data annotation attribute.
Published:

C# - Get time zone and UTC offset from latitude and longitude (GPS coordinates)

I recently set up an Instagram feed for a travel blog and found that the Instagram API only supplies the UTC created date/time of each image, and doesn't supply the user's UTC Offset (as the Twitter API does), so the only thing you have to work with are the latitude and longitude (lat/long) coordinates to find out the timezone and UTC Offset of where the image was posted.
Published:

Using MVC 4 Web Api with jQuery DataTables

With the release of ASP.NET MVC 4 and Web Api, creating JSON web services has never been easier, which makes it perfect for populating jQuery DataTables via Ajax.
Published:

MVC CheckboxList for property of type IList<Enum>

This is an extension method for creating a checkbox list for a list of enum values (IList<Enum>). It's a modified version of the CheckboxListForEnum extension method I found on the Xango project. Their version creates a checkbox list for a property that contains a single enum value.
Published:

MVC3 redirect to mobile site and stop executing

Response.Redirect(url, true) does NOT stop executing. Automatically redirect iPhone to mobile site.
Published:

ASP.NET MVC3 + Altairis Web Security Toolkit

In this post I'll show you how to install and configure the Altairis Web Security Toolkit in an MVC3 application. The Altairis Web Security Toolkit is a simple, easy to use ASP.NET Membership Provider with a clean table structure. It's much nicer to work with than the default ASP.NET Membership Provider.
Published:

NHibernate - Map Umbraco member profile properties with Custom Interceptor

I'm writing an application that uses NHibernate as the data layer, but is required to integrate with an existing Umbraco system. Specifically, I have a User class that needs to map to an Umbraco member.
Published:

Populate ASP.NET dropdown list with month names using LINQ

Using LINQ and the Enumerable.Range method it's possible to populate a dropdown list of month names in a single line.
Supported by