Categories
Programming

IISExpress.exe Exited With Access Violation

I was happily typing away at some ASP.NET Core controllers and views, calling a view component to render out some paging links, when this happened… The program iisexpress.exe’ has exited with code -1073741819 (0xc0000005) ‘Access violation’. No exception visible in Visual Studio. No indication of where the error was. Nothing. The Internet supplied links to […]

Categories
Programming

Entity Type IdentityUserLogin Requires a Primary Key

You will usually come across this problem in .net Core Entity Framework when you first override the OnModelCreating method in your DbContext. The entity type ‘IdentityUserLogin‘ requires a primary key to be defined. If you intended to use a keyless entity type call ‘HasNoKey()’. If you check your DbContext class, you’ll see that when you […]

Categories
Programming

Check Certificate Expiry Date in .NET Core

I needed to check the certificate expiry date in an NUnit test. The below snippet can be used to check any certificate properties, using a custom certificate validation callback. All you need to do is read the properties you are interested in within the callback so you can check them afterwards. DateTime notAfter = DateTime.UtcNow; […]

Categories
Programming

.NET Core Entity Framework Migrations

When you don’t want to script out your own database, Entity Framework Core has your back. When you change your database context or the models it uses, you can use a couple of commands to create and update your database to keep it in sync with your model. These examples run in the Package Manager […]

Categories
Programming

Import IIS Log Files to SQL Server with Web Log Importer

In the past I have used Log Parser Studio to run SQL style queries against IIS logs, but it can take a fair bit of time to do this. Sometimes you just want to run a quick SQL query against the log data that IIS has collected. SQL Server is a super quick way of […]

Categories
Programming

Using .NET Core Identity Without the Standard Pages

This is a quick article about using .NET Core Identity without the standard pages. It was almost titled “why does .NET Core Identity ignore my LoginPath that I set in options?”. Let’s start with a common chunk of code that you’ll find in your Startup.cs file if you’ve added identity to your project… services.AddIdentity<ApplicationUser, ApplicationRole>() […]

Categories
Programming

Html.RenderAction Equivalent in .NET Core MVC

If you were a fan of ASP.NET MVC Widgets using Html.RenderAction, you might be a bit stunned that RenderAction is nowhere to be found in .NET Core. Don’t worry, though, because there is a Html.RenderAction equivalent in .NET Core MVC and it’s called View Components. View Component Class The view component class is quite a […]