“Code Tips” or “Programming” (both aliases for this term in my site’s taxonomy) is my category for whatever posts I’m able to come up with, that handle programming, code quality and/or handy workarounds. Is code directly involved? Then the post should be filed under here!
This is meant to distinguish posts from different things, like configuration or user analytics -related posts. Even tips of fixing Azure DevOps pipelines go elsewhere, because that’s not programming.
I don’t know about you, but it’s happened to me a few times: fire up your Azure functions project, hit F5 to start debugging project builds without errors, Azure Functions host starts… And shuts down right away. This article has a few quick and simple tips on how to extract a bit more information from the Azure Functions host (func.exe), when it’s just silently failing. This means by default you won’t get any information about what’s going wrong. However, a couple of steps should get…Continue reading How to extract more information out of your Azure Functions host failing silently?
This post details my very simple solution to an extremely unnecessary and kind-of simple error that I encountered when logging into SharePoint. However, you could run into the same error after configuring Azure Active Directory authentication to a custom web application. The error message comes in at least 2 variants. These are shown below: AADSTS90056: This endpoint only accepts POST, OPTIONS requests. Received a GET request. The other one I’ve seen doesn’t even mention OPTIONS, just POST: AADSTS900561: The endpoint only accepts POST requests. Received…Continue reading How to resolve AADSTS90056 – “The endpoint only accepts POST requests. Received a GET request.”
You might’ve heard the news – Delve Blogs are on the way out, leaving your users without a blogging platform on Office 365, and their data homeless. And by homeless, I mean deleted pretty soon. And by pretty soon I mean really soon. Might be a good time to start thinking about storing it somewhere else instead! While we’re all still waiting to see whether Microsoft sticks to their ambitious schedule (partial content freeze in December 2019, total content freeze in January 2020, and finally,…Continue reading How do you migrate your Delve Blogs content to Modern SharePoint?
Another case, where there’s plenty of documentation, but it just doesn’t seem to be comprehensive enough or just doesn’t apply for any of the cases that I have – for whatever reason. Maybe my cases are wrong, or I’m just bad at googling, but I’ve struggled to find a good page documenting this. Perfect case for another blog post about the topic, then – perhaps someone else will find it useful! This post answers the question: How to get Claims for a user in .NET…Continue reading Iterating Group memberships using Claims in .NET Core
When you’re in your .NET Core project, it’s always easy: you just register your DbContext in ConfigureServices, and then inject it into whichever Page, View or Controller you might need it in. However, when you have another project or solution you’re working on and you’d still like to use the same DbContext and your entity classes in it, you have to find another way to do it! What should we do, then? Description Let’s first take a look at the use cases and tech stack.…Continue reading How to create a DbContext from just a connection string?
I ran into another interesting one when working with a .NET Core 3.0 project and Entity Framework Core – this time, RuntimeIdentifier configuration causing trouble. In short, running Update-Database (to apply code-first migrations to your local database) locally would return this, annoying error: I suspect this can happen with any x86 runtimeIdentifier, but the one I had specified in my .csproj-file was this: This value (or similar) is required for a self-contained ASP.NET Core deployment. And I’m sure there are a few other reasons why…Continue reading EF Core fails to load hostpolicy.dll when RuntimeIdentifier is win-x86
Just a quick piece of documentation, as this piece of code has changed in different versions of .NET Core 3.0 so far a few times. Need to have things like this written down somewhere! UriHelper / NavigationManager with .NET Core 3.0 Both of these helper libraries do essentially the same thing: navigate/browse/redirect the user to a different address, component, page or view in or by your web app. What you normally use this library for is exactly the same in all versions I’ve worked with,…Continue reading How to use UriHelper or NavigationManager in .NET Core 3.0 & Blazor?
This post describes the easiest way to show description texts for properties in ASP.NET MVC 5. Sounds simple, right? We can use something like @Html.DescriptionFor(x => x.Property), right? Alas, it’s not that straightforward. A bit surprisingly, there’s no ready-made helper function for this. I’m saying “surprisingly”, because I feel like MVC 5 really already has all the bells and whistles – AND the kitchen sink. But no, it does not have a helper for getting a description of a property :) You can, however, define…Continue reading How to get the Description for a property in ASP.NET MVC 5?
Welp – just ran into this one, and as I expect others to encounter the same issue, better document in right away! So in Blazor, I was crafting a simple component that’d display some data in a nice way. Being lazy and crafty, I thought I’d copy-paste some similar code from an earlier POC I had built, since I knew it worked. The component was overriding a method called “OnInitAsync”, and it just nicely fetched data after initialized. But alas, it didn’t. Not anymore. I…Continue reading ‘__generated__Index.OnInitAsync()’: no suitable method found to override
Building a proof-of-concept on .NET Core 3.0 preview 7 I ran into issues when developing web APIs. This release is production-ready (according to Microsoft -see below), but every now and then you run into really unintuitive and sometimes surprising issues. Go LiveNET Core 3.0 Preview 7 is supported by Microsoft and can be used in production. We strongly recommend that you test your app running on Preview 7 before deploying Preview 7 into production. If you find an issue with .NET Core 3.0, please file…Continue reading How to resolve build failing with .NET Core 3 and Microsoft.AspNetCore.Mvc.Versioning
Ha – another one, that ended up being a simple fix, but since nobody actually explains it well, took me an hour to figure out. This post ended up being another example of my “I’m going to document every single fix that took me more than 10 minutes to figure out, since that’ll help me (and others) the next time the same issue arises.” blogging strategy. Snappy name, right? 😅 Ah, well, naming things is really, really difficult. Anyway, I ended up banging my head…Continue reading How to fix Microsoft.AspNetCore.Mvc.TagHelpers not being rendered!
This post describes how you can access your Entity Framework Core model classes and the database context in your Azure Functions. In my example I’m using EF Core 2.1, but the main principle should be the same for later versions as well. Please note, that I use Azure functions runtime v2 (but it should work the same in v3 !) Another easy one, that I was unable to find much guidance on! But first, let’s start with the basics. Why would you want to have…Continue reading How to access Entity Framework Core’s DbContext in an Azure Function?
Welp – another interesting error encountered while deploying Azure Functions to Azure. So, everything runs nicely locally, but when you deploy your well-tested, functional and pretty code to run them in the cloud, you’ll just get these ugly and unfriendly errors. Long story short, “Function compilation error” is what you’re faced with. Example error below: Function compilation error Microsoft.CodeAnalysis.Scripting.CompilationErrorException : Script compilation failed. at async Microsoft.Azure.WebJobs.Script.Description.DotNetFunctionInvoker.CreateFunctionTarget(CancellationToken cancellationToken) at C:\azure-webjobs-sdk-script\src\WebJobs.Script\Description\DotNet\DotNetFunctionInvoker.cs : 314 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at async Microsoft.Azure.WebJobs.Script.Description.FunctionLoader`1.GetFunctionTargetAsync[T](Int32 attemptCount) at C:\azure-webjobs-sdk-script\src\WebJobs.Script\Description\FunctionLoader.cs : 55 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at async…Continue reading Sudden “Function compilation error” for an Azure Function
Have you ever struggled to make your ASP.NET MVC views format your properties of type DateTime correctly? I have. And I’ve been shot in the leg by weird hacks made by both myself (just 6 months earlier) and someone else. .NET Date/DateTime formatting is an endless bag of funsies in general. So I thought I’d finally document the different ways one can set up the formatting of DateTime fields in ASP.NET Core projects specifically. Or at least all the ways I’ve found so far! :)…Continue reading How to format DateTimes in ASP.NET Core?
Every now and then, an API or a method call comes along, that you need to be very careful with. “Microsoft.SharePoint.Client.Web.AddSupportedUILanguage()” seems to be one of them. In this post, I’ll try and document my findings and workarounds for said method! Issues and solutions Posts Related to “Problematic behavior of web.AddSupportedUILanguage(int lcid) in SharePoint 2013 and 2016”:SharePoint Localization – a (somewhat) comprehensive how-to!SharePoint Home, Hub, Sites, Start… What?5 ways to enable Custom Scripts for a SharePoint site collection
This article explains how you can access an Azure Function’s Application/Environment settings/variables from your C# code. Different versions of Azure Functions have different ways to access the Azure Function settings, but this page should explain the easiest way to get your application setting values for each Azure Functions version! While this is something I need often, it has been another little thing, that I always forget – so better document it somewhere. How to get application settings in different runtime versions of Azure Functions? This…Continue reading How to get application settings for your Azure Function App using C#?