Blog Posts for: Aspnet

Communicate from an Azure WebJob to your website with SignalR

14 July 2015

Introduction Azure WebJobs are great for offloading long running tasks from you website, but sometimes you find that you may want to communicate the progress of those tasks back to the user. In this blog post I will demonstrate how you can communicate progress from an Azure WebJob back to the browser using SignalR. It is important to understand that the SignalR connection is made between the web server running the ASP.

Create test data with NBuilder and Faker

07 July 2015

For many web applications you may want to generate some initial, semi-realistic test data for your development and testing environments. Entity Framework provides a handy mechanism through which you can achieve this, namely seed data. You can read Mike Wasson’s blog post on the ASP.NET website for some background on how to use create seed data with Entity Framework Code-First migrations. The Seed mechanism is handy for populating the database, but how do you create the actual test data?

Popup OAuth authentication with ASP.NET and SignalR

30 June 2015

Introduction One of the SaaS tools which I like to use for all sorts of small app-to-app integrations is Zapier. If you have ever used Zapier before you may have noticed that authenticating with one of the many applications with which it integrates does not actually navigate away from the current page that you are on, but instead uses a simple HTML popup dialog to authenticate the user. For a recent project I was involved in I had to do something similar, so I have extracted the techniques into a demo application and I am writing this blog post to show how easy it is to do something like this.

Resolve your DbContext as an interface using the ASP.NET 5 dependency injection framework

19 May 2015

When developing ASP.NET applications, I prefer to have my database context implement an interface and then inject the interface, as this allows me to more easily mock the database context during unit tests. So in a typical application, I would do something like this: public interface IApplicationDbContext { DbSet<Episode> Episodes { get; set; } DbSet<ApplicationUser> Users { get; set; } int SaveChanges(); Task<int> SaveChangesAsync(CancellationToken cancellationToken); } public class ApplicationDbContext : IdentityDbContext<ApplicationUser>, IApplicationDbContext { public virtual DbSet<Episode> Episodes { get; set; } public ApplicationDbContext() { .

2 Approaches when rendering a list using the Bootstrap grid system

12 May 2015

Introduction Rendering a list of items in ASP.NET MVC inside a grid (HTML Table) is straight forward and easy. You simply but everything inside an HTML Table tag and generate table rows for each item in the list you want to render. But what to do when you want to render it as a list of rows and columns? Well, Bootstrap has a grid system which allows you to layout items as rows and columns.

Using the ASP.NET OAuth providers without ASP.NET Identity

27 April 2015

Introduction I think very few ASP.NET developers realise that the ASP.NET authentication providers and ASP.NET Identity really have nothing to with each other. It is two completely independent technologies which are brought together nicely by the default ASP.NET MVC project template to allow users to sign in with the social media accounts, or link a social media sign in to their existing user account. ASP.NET Identity is the technology which provides user management, role management and authentication.

Advanced configuration in the ASP.NET 5 Generic OAuth Provider

21 April 2015

Introduction In my previous blog post I introduced the new generic OAuth 2 authentication provider which has been added to ASP.NET 5 by showing you how to configure it to authenticate with GitHub. In this blog post I will discuss two more advanced configuration options, namely requesting extra permissions via the Scope, and retrieving user information after authorization. The code I use in this blog post is mostly a straight forward copy-and-paste exercise from the sample in the ASP.

An introduction to the ASP.NET 5 Generic OAuth Provider

14 April 2015

Introduction Over the past 2 years I have been involved in the OWin Authentication Providers project, which enables developers to allow users of their ASP.NET applications to sign in with a wide range of services such as GitHub, LinkedIn, Yahoo and others. It started off with a blog post on how to allow users to sign in with their Google+ accounts via OAuth, and then it went on to LinkedIn and Yahoo and before long a Nuget package was born and the number of providers grew to where it stands at 23 today.

The ASP.NET Developer's guide to Bootstrap

24 March 2015

Introduction Twitter Bootstrap is one of the most widely used CSS frameworks at the moment and there is a massive supporting ecosystem in themes, components, tutorials and the likes. Since Visual Studio 2013, the standard ASP.NET project template has also been based on Twitter Bootstrap. Now, along with the popularity of Bootstrap there has also been the inevitable backlash from people complaining that also website now look the same. The framework itself has also grown quite large over time and inevitably contains a lot of excess CSS classes which you do not use in your applications.

Hey ASP.NET developers: Twitter is stealing from your 140 characters

20 March 2015

Introduction A picture is worth a thousand words, so check this out: I have a tweet with the words “ASP.NET”, which is 7 characters and yet according to Twitter I have used up 22 characters already… Twitter uses a built in link shortening service which shortens all links using its own link service (http://t.co). It does this for a number of reasons which they describe in the document About Twitter’s link service.