C#

Asp.Net Mvc Areas in EPiServer - Part 2

Asp.Net Mvc Areas is a great way to organize and structure your EPiServer site. Once you have multi-tenant site where the same EPiServer installation with the same set of libraries, styles, script set and other assets is handling more than single site - Asp.Net Mvc Areas become really handy to group particular site's specific assets and other stuff together under single folder. This also gives developers more obvious and more clear picture of the project setup. However we all know that there is no native support for Asp.…

Keep reading

Content Area - Under the Hood, Part 3

This is last blog post in series under the hood of Content Area. In this blog post we will take a look at how and what exactly could be customizable while content area is being rendered. Where and how developer can hook in, what can be overridden and controlled. Parts in this series: – Part 1: Registration and Discovery – Part 2: Template Selection – Part 3: Extensibility Overview Following parts and pieces can be customizable, changeable or replaced by other code completely: Change renderer - It's possible to change they guy who…

Keep reading

FeatureSwitch meets Glimpse

FeatureSwitch library got yet another plugin in its family. Glimpse is an amazing framework for troubleshooting and tracing your web application, even in production environment. If by coincidence you are a consumer of this framework and also use FeatureSwitch library, then now they run together. You can access your features through Glimpse control panel. Installation You need to install a package from nuget.org feed: > Install-Package FeatureSwitch.Glimpse Using FeatureSwitch.Glimpse package you can get an overview of your features and its state through FeatureSwitch tab. There is also…

Keep reading

Chasing for NullReferenceException in EPiServer Relate+

This is a blog post telling a short story about one of the developer’s nightmare beast hunting case – System.NullReferenceException. Hunting Game Starts Once up on a time I received an interesting issue regarding user authentication in one of the projects. Issue description was telling that it was not possible for the users to login to the site. We were using EPiServer Relate+ in that particular area of the application. At least I had something for the exceptional case on production server. Following message was observed in local Windows…

Keep reading

Initializable modules without EPiServer

EPiServer initialization modules is a great feature to provide plugin facilities for the hosting application. I find initialization modules pretty handful in cases when you need to initialize some library, configure some stuff or do whatever needed at application start-up. However there are times when you have to develop site without wonderful backup platform that takes all boring boilerplate code away and provides with much awesome stuff and features. Let’s switch to ordinary Asp.Net Mvc application initialization code: [assembly: OwinStartupAttribute(typeof(WebApplication1.Startup))] namespace WebApplication1 { public partial class…

Keep reading

Lambda expression and small “around” method to reduce DRY

When you are acting as façade or in any other “forward-like” role sometimes error handling may come pretty boring stuff to deal with. For instance if you are acting as front-end client proxy class for some REST Api behind the scenes, code below may look familiar – that you have to replicate yourself all the time and catch for instance in this case IO error and response content format error (if they return invalid formatted Json object). protected void Operation1() { try { // some black magic happens here.. } catch (HttpRequestException e) { // handle IO…

Keep reading

Format Your Exception Message Properly

Not so Nice Failure I was hacking around NServiceBus (NSB) application and came across pretty unpleasant failure from NSB. So in short we were using Unicast bus that basically means that producer-side of the message has to have a configuration set to which NSB endpoint particular message should be sent. In this case we were using Microsoft Azure Storage Queues as physical transport level. In case when you don’t have a particular configuration to instruct NSB where the message has to be delivered you may encounter following exceptional message:…

Keep reading

Pragmatic problem solving – Answer to the EPiServer forum question

At some point I was questioned about how I’m learning and finding the answers. Generally for the learning process a huge inspiration came from “Pragmatic Thinking and Learning: Refactor Your Wetware” by Andy Hunt. Software development happens in your head. Not in an editor, IDE, or design tool. You’re well educated on how to work with software and hardware, but what about wetware—our own brains? Learning new skills and new technology is critical to your career, and it’s all in your head. Walk-through learning and research…

Keep reading

Tiny C# clean-up improves understanding of the code

I’m starting to collect small fragments from everyday life to understand and increase understanding and readability of code I’m coming across. First piece in this category is gone which I came across while contributing to one of the open source modules. Original fragment: { IEnumerable btypes = GetBlockTypes(); List blockproperties = new List(); int x = 0; foreach (BlockType type in btypes) { x = 0; foreach (PropertyDefinition def in type.PropertyDefinitions) { x++; blockproperties.Add(new TypePropertyResultItem { TypeName = x == 1 ? type.Name : “”, PropertyName = def.Name, Description = def.TranslateDescription(), DisplayName = def.TranslateDisplayName() }); } } return blockproperties; } Modified…

Keep reading

Parse and Validate Quartz JobDataMap

Once you start to implement web site driven by EPiServer Commerce the necessity of scheduled background job(s) sooner or later will rise. A nice approach and existing framework is used in EPiServer Commerce solutions – background jobs are scheduled and Quartz.Net. As we all know scheduled background jobs are sort of agents or workers that do the dirty job over night or any allowed time window to fetch, process, calculate, recalculate, push or do whatever other fancy complex operations that may take time and valuable resources to complete. Nice…

Keep reading