Blog Posts for: Asp.net

Accessing the OIDC tokens in ASP.NET Core 2.0

01 August 2017

Earlier the year I wrote a blog post which described how to access the JWT Bearer token when using ASP.NET Core 2.0. Though that was specifically for when using the JWT middleware, you could also use that technique when using the OIDC middleware. In ASP.NET Core 1.1 So for example, in ASP.NET Core 1.x, if you wanted to access the tokens (id_token, access_token and refresh_token) from your application, you could set the SaveTokens property when registering the OIDC middleware:

Overriding the NameClaimType when using the ASP.NET Core OpenID Connect middleware

30 May 2017

When using the ASP.NET Core OpenID Connect middleware, after a user has signed in you can access the name of the user by using the User.Identity.Name property. What this does under the cover is to look for the http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name claim type and then return that value. In the case of Auth0, we actually return a user’s name in the name claim of an id_token and this does not get automatically mapped to the http://schemas.

Access the JWT bearer token when using the JWT middleware in ASP.NET Core

26 May 2017

When using JSON Web Tokens (JWTs) as Bearer tokens in your ASP.NET Core Web API, it may sometimes be required to access the actual token which was passed to the API somewhere else in your API. For Remote Map for example I have the requirement to access the user’s full profile under certain conditions. I want to store some of the user’s personal information in the local database, and in order to obtain their information I have to call the /userinfo endpoint of the Auth0 Authentication API.

Introducing Remote Map: An end-to-end Auth0 sample for .NET developers

22 May 2017

It seems I have not had much success with announcing my intentions to start a new project and blog about it. Before long something more interesting comes along and I am off in another direction and working on a new pet project. Case in point: GeoToast Well, seems I don’t learn as I am trying this again. This time however I have better motivation to get this done (I think).

Determine a user's location from their IP Address in ASP.NET Core

18 May 2017

To determine a user’s location in a web browser you can use the HTML Geolocation API. There are however a couple of issues with this. First, the user will be prompted to give permission for you to determine their location. If they deny this request, then you will not be able to determine the location. Secondly, this is a JavaScript API, and therefore a client-side solution. But what if you want to determine a user’s location on the server?

Creating a Serverless Application with ASP.NET Core, AWS Lambda and AWS API Gateway

07 May 2017

In my previous blog post I gave an overview of how you can create a serverless application using .NET Core and AWS Lambda. In this blog post I will show a similar - yet quite different - programming model. Instead of using just plain .NET Core, I’ll be using ASP.NET Core with AWS Lambda. A quick reminder from my introductory blog post in this series may be in order.

Creating a Serverless Application with .NET Core, AWS Lambda and AWS API Gateway

11 April 2017

Previously I gave an overview of the programming models when using NET Core with AWS Lambda, and I also showed how to create an image compressor in Lambda and C#. This time around we’ll put together a simple Web API with a couple of endpoints which can be called from any client application. The API I’ll create will utilize NodaTime library created by Jon Skeet to return a list of time zones based on the Time Zone database.

Getting started with .NET Core and AWS Lambda

22 March 2017

This blog post will provide you with a brief introduction to using C# and .NET Core with AWS Lambda and also look at the different programming models available when using .NET Core with Lambda. The reason why I started looking into this was because I wanted a dead simple hosting solution for GeoToast. And yeah, it has been a while since I have written about GeoToast. I spent a month in Japan, and sightseeing was higher on my list of priorities than coding…

TWiG #2: Frustrations with .NET Core tooling and VS Code

05 February 2017

Things I learned Rename Refactor in VS Code In last week’s update I alluded to the fact that I miss many of the refactorings which is offered by Visual Studio and Resharper. One good find this week is that VS Code at least has Rename Symbol functionality. As explained by the VS Code Documentation: Some languages support rename symbol across files. Simply press F2 and then type the new desired name and press Enter.

Handling validation responses for ASP.NET Core Web API

31 January 2017

I have been working on GeoToast and one of the things I needed to handle was returning a response when model validation fails when calling any of my API endpoints. I am also using Fluent Validation for my model validation which I talked about in my previous post, but that has no bearing on this blog post. This blog post deals with ModelState and FluentValidation ultimately updates the ModelState so whether you are using normal data annotations attribute validation, or Fluent Validation, this will work the same.