Over the years there's been a number of projects designed to make using Razor templates from your own code easier. For a while, these third-party libraries were the only way to easily use Razor outside ASP.NET MVC because using the ASP.NET code directly was too complicated. That started to change with ASP.NET Core and the ASP.NET team has slowly started to address this use case. In this post we'll take a look at the current bleeding edge of Razor and how you can use it today to enable template rendering in your own application.
Recently I've been using more and more Vue.js in the client code for my ASP.NET MVC websites. It provides a great balance between modern interactive client functionality and server logic. However, one area that's been troubling me is how to integrate the powerful built-in
ModelState server-side validation framework with the client, particularly in WebAPI or other service-based scenarios. Ideally, I'd like to display server-side validation errors on the client when data fails to validate due to validation attributes like
[Required]. This article shows one way to do that.
This short post explores a really simple technique for using the same C# object as a view model on both the client and server.
I've seen an interesting static site use case come up a few times recently where someone wants to use a static generator along with an existing dynamic site. The idea is that they would generate certain resources statically at build-time of the dynamic site and then only rely on the dynamic runtime for pages that really need it. I've long suspected that Wyam would be great in this role, particularly for ASP.NET MVC sites given that it can read the same Razor layout files. I finally got motivated enough to give this a try and will detail how to do it in this blog post. It turns out it's not hard at all and works really well once you've gotten everything set up.
I've been playing around with Serilog and have been really, really impressed. If you're not familiar with it, Serilog provides a very nice logging API with the ability to log entire object graphs in addition to flag messages. It's also really extensible and has a lot of community support.
Except for direct screen output, I really dislike coded string literals. Using strings to refer to properties, methods, classes, etc. makes it much easier to introduce code quality problems. This includes things like mistyped identifiers, missed refactoring renames, and poor code analysis capabilities. I am constantly on the hunt for ways to remove these "magic strings" and replace them with strongly-typed counterparts. This post describes several of the tools and techniques I've found that work well. While this post addresses the elimination of magic strings from ASP.NET MVC web applications, many of the strategies are applicable to other code as well.
So you want to color the rows of your KendoUI grid based on the grid data. This is one of those problems that seems like it should be really simple, but if you search the Internet you'll turn up a bunch of convoluted answers. Most of the recommendations relate to row templates. That's fine if you want to completely restyle the grid rows, but just changing the background color shouldn't be so hard. Thankfully, there is a better way.
From reports to scan sheets, the need to generate PDF files has been present in every line-of-business application I’ve ever worked on. In the past, I’ve used a variety of tools to achieve this such as SQL Server Reporting Services or Telerik Reporting. While these kinds of tools work well enough for generating reports straight from the database, it’s been surprising how few resources exist to aid in generating PDF files from arbitrary data.
Exporting grid data is a common need for line-of-business applications. Once you’ve got all the great data presented, filtered, etc. how to you allow the user to download it and continue playing with it? There are many approaches discussed online to solve this (see here and here). Unfortunately, I didn’t find any of them really had the polish I wanted and that my users demand. There are really two categories of solutions to this problem: