Img_0738_large

Kevin Rich

Mediaphile

This Is a Rebellion

I'm a bit of a mediaphile and I love Star Wars. So when I realized that Fatboy Roberts (the mind behind the Geek Remixed albums) had released a mix of Star Wars music, I had to jump on board. Now I share with everyone else.

Enjoy.

Read More

March 23, 2017

Entity Framework SQL Debugging

Using Lambdas to Log Generated SQL

Scenario

My boss is a SQL guy, a DBO by trade. Every now and again, he wan't to know what SQL my application is running against the database.

I am not a SQL guy. I've been using EntityFramework and lambdas from nearly the beginning of my .NET adventures. I can read and write SQL...

But why?

Solution

Lucky for me, Entity Framework provides a . . .

Read More

February 10, 2017

Restricting Access to Routes without [Authorize] Filter

Locking down Swagger, Elmah, and other "magic" endpoints

Create a Delegating Handler

In this example, I want to lock down the \swagger endpoint from an ASP.NET 4.6.1 MVC web application.

 public class SwaggerAccessMessageHandler : DelegatingHandler { protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { if (IsSwagger(request) . . .

Read More

December 05, 2016

AutoMapper / ReSharper Configuration

Fixing the cause of a ridiculous slowdown

The Challenge

While working on a project, I noticed that Visual Studio ground to a halt while I was working on a rather in-depth AutoMapper profile. Something clicked in the back of my head, remembering a similar issue I experience about a year ago. Both times I had experienced this issue, the slowdown happened while editing an AutoMapper . . .

Read More

November 20, 2016

Dealing with XML

A quick guide to the XmlSerializer

I don't work with XML Serialization much, but every now and again I find myself working on something that requires a little XML love. I recently answered a StackOverflow question regarding the subject.

What's covered

  • Understanding the parts of an XML document
  • Setting up a POCO class to mirror an XML document
  • Deserialization of an XML . . .

Read More

November 06, 2016

Configuring Swashbuckle for API key Authentication

A followup to adding Authentication Filters

Scenario

Recently, I wrote about adding custom authentication filters to a .NET MVC project. As a user of Swashbuckle, I needed to factor the filter into my swagger specs.To do this,we need to configure the Swagger configuration to include the api-key requirement information and configure the SwaggerUI configuration to inject some JavaScript. . . .

Read More

July 19, 2016

Adding User Claims via API keys in WebApi 2

Adding a Custom Authentication Filter

Scenario

I have an API that I wish to lock down via an API key the user will embed in the request header. We will accomplish this using the WebApi.AuthenticationFilter NuGet package to create a custom AuthenticationFilterAttribute which will check the incoming request header for an "api-key" key and related value.

Project . . .

Read More

July 19, 2016

Archive

Cover image credit: http://whoiskevinrich.com