Quantcast
Channel: briancaos – Brian Pedersen's Sitecore and .NET Blog
Browsing all 276 articles
Browse latest View live

Image may be NSFW.
Clik here to view.

IdentityServer use IdentityModel to get user token and user info

Using IdentityServer have been made easier with the IdentityModel helper library. The library implements extension methods that maps the input and output to classes. GET ACCESS TOKEN: Use the...

View Article


Image may be NSFW.
Clik here to view.

Sitecore CTRL+S fires item:saving event twice

If you have ever tried to implement your own Sitecore item:saving or item:saved event handlers, or have tried to extend the SaveUI pipeline, you might have noticed that the events gets fired twice if...

View Article


Which of my old Sitecore posts are still valid in Sitecore 9?

I have been writing Sitecore blog posts since April 2006. The first ones were for Sitecore 4.2. Now, 13 years later, some of the old posts are still valid, while others are obsolete as the Sitecore API...

View Article

Newtonsoft serialize property that is an array and a string

IdentityServer4 has a strange way of returning roles. If there is only one role, the property is a string: { "sub": "55568182-9273-4c6f-8d61-6555f7f02551", "role": "role001" } But if there is more than...

View Article

HttpClient POST or PUT Json with content type application/json

The HttpClient is a nifty tool for getting and sending data to a URL, but it works differently from the old fashioned WebRequest class. The content type is added to the post data instead of added as a...

View Article


Image may be NSFW.
Clik here to view.

ID or Id? Naming conventions in code

This topic is not as toxic than the tabs-vs-spaces or 2 vs 4 indents discussion, but it’s still something every coder I have met have an opinion about, no matter the programming language: Which is...

View Article

Image may be NSFW.
Clik here to view.

Sitecore publish certain items on save

My Sitecore solution have some items, where changes to certain fields are so critical that they need to be published immediately. So when my user presses the Save button, I will open a popup dialog,...

View Article

Sitecore Publish Items using the PublishManager

Sitecore have two entries to publishing: Create a new Publisher and call Publish() or PublishAsync() Use the Sitecore.Publishing.PublishManager You should use the PublishManager. Sitecore introduced...

View Article


.NET Core MVC Web API – control DateTime format in JSON output using...

When creating API’s with .NET Core MVC, you can control the JSON output by adding JsonOptions to the controllers: public void ConfigureServices(IServiceCollection services) { ... ......

View Article


Because this call is not awaited, execution of the current method continues...

This C# warning occurs if you call an async method from your non-async code. Imagine you have this imaginary async method: internal class QueueRepository { public async Task AddMessage<T>(T...

View Article

Image may be NSFW.
Clik here to view.

.NET Core API and CORS – allow POST from Javascript using...

After hours of debugging, I finally managed to apply CORS correctly to my .NET Core 3.0 Application. Like so many other before me, I used this article as reference: Enable Cross-Origin Requests (CORS)...

View Article

ASP.Net Core API –“‘s’ is an invalid start of a value. Path: $ | LineNumber:...

If you create an ASP.Net Core API Controller, and you wish to create an endpoint that can accept any string, you would expect this to be correct: using Microsoft.ApplicationInsights; using...

View Article

Image may be NSFW.
Clik here to view.

Sitecore use global and environment variables in config files

The Sitecore config files are a complex machine and it requires a healthy mind to work with it. Fortunately Sitecore have implemented a few tricks to ease our pain. This article focuses on 2 parts:...

View Article


.NET Core Catch Model Binding Exceptions

In .NET Core, if you create an API project, and you have an controller receiving an object you defined yourself, the controller will not be called if you use the wrong model, or if the model is not in...

View Article

Sitecore and Application Insights – How to remove 90% of all log lines...

In this article I will explain how you can remove up to 90% of all log lines from the Application Insights log, but still keep every log line in the file log. All of this without loosing any important...

View Article


.NET Core Api – Catch exceptions using a middleware

In .NET Core, we are starting to get used to the fact that nothing comes for free, and in the world of ultimate freedom of choice, every feature needs to be implemented by us. This includes error...

View Article

Sitecore use item:deleting event to avoid deletion of items

The Sitecore extendable model allows you to build business rules into your Sitecore solution. This is an example where I disallow deletion of certain items when a certain business rule is true. This...

View Article


Sitecore Create/Read/Update/Delete/Copy/Move/Rename item – the beginners guide

New Sitecorians often ask the most trivial questions, and I am happy to answer them. This question popped up lately: How do you perform basic CRUD operations on your Sitecore items? Well, it’s easy:...

View Article

Command line parameters in .NET Core Console Applications

When implementing .NET Core console applications, you can extract the command line parameters from the void Main(string[] args) method, but it can be a little tedious to do so. To help with the...

View Article

Image may be NSFW.
Clik here to view.

Azure App Configuration – Getting the connection string from appsettings.json

Azure App Configuration is a services that provides a central place to manage application settings, and it provides cool features like feature flags and auto refresh of settings when they are changed....

View Article
Browsing all 276 articles
Browse latest View live