ASP.NET MVC

The Bleeding Edge Of Razor

Using the Razor view engine in your own code.

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.

Read more...

Using ASP.NET ModelState With Vue.js

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.

Read more...

Using The Same Object For Server And Client View Models

This short post explores a really simple technique for using the same C# object as a view model on both the client and server.

Read more...

Integrating Wyam Into An ASP.NET MVC Site

I heard you like static sites, so I put some static site in your dynamic site

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.

Read more...

Easy Performance and Query Logging in ASP.NET with Serilog and MiniProfiler

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.

Read more...

Eliminating Magic Strings in ASP.NET MVC

One man's quest to get rid of quotes.

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.

Read more...

Introducing FluentBootstrap

Extensions, helper classes, and other goodies to help you use the Bootstrap CSS framework.

FluentBootstrap Web Site
GitHub
NuGet

Read more...

Simple Row Coloring in a KendoUI Grid

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.

Read more...

Using ASP.NET MVC and Razor To Generate PDF Files

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.

Read more...

How I Export Kendo Grids to Excel (or CSV)

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:

Read more...

open source (18) ASP.NET (15) ASP.NET MVC (14) static site generator (9) programming (8) Azure (7) Wyam (7) Roslyn (7) NuGet (6) devops (5) .NET Compiler Platform (5) Razor (4) personal (4) Vue.js (4) Entity Framework (4) LINQ (4) database (4) KendoUI (4) KendoUI MVC (4) grid (4) csharp (3) scripting (3) meta (3) T4 (3) XML (3) Mono (3) GtkSharp (3) tools (2) Cake (2) msbuild (2) magic strings (2) Azure Cosmos DB (2) Azure Functions (2) LINQ to Entities (2) strings (2) algorithms (2) LINQPad (2) blog (2) CSS (2) export (2) CSV (2) HtmlHelper (2) Entity Framework Code First (2) Nxdb (2) XQuery (2) Blazor (1) WebAssembly (1) Netlify (1) FTP (1) documentation (1) configuration (1) DSL (1) enum (1) stdin (1) stream (1) console (1) cli (1) npm (1) node (1) microdependencies (1) collections (1) concurrent (1) HashSet (1) Twitter (1) Serilog (1) MiniProfiler (1) logging (1) OWIN (1) templating (1) design (1) web (1) JavaScript (1) API (1) IIS (1) debugging (1) LINQ to SQL (1) FluentBootstrap (1) Bootstrap (1) RazorDatabase (1) GitHub (1) AppVeyor (1) fluent interfaces (1) method chaining (1) style (1) conventions (1) PDF (1) Acrobat (1) Excel (1) checkbox (1) postback (1) icon fonts (1) icons (1) SQL (1) SQL Server (1) round robin (1) DotNet (1) Dictionary (1) MultiDictionary (1) data annotations (1) persistence (1) object persistence (1) NiceThreads (1) Threading (1) Monitor (1) ReaderWriterLockSlim (1) locking (1) ILocker (1) networkdays (1) weekdays (1) ButtonPressEvent (1) Context Menu (1) ContextMenuHelper (1) Menu (1) Popup (1) Popup Menu (1) CellRenderer (1) TreeModel (1) TreeView (1) TreeViewColumn (1)