Dave Glick (Page 5)

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...

Creating A One-Page GitHub Profile With Wyam

It's been a little while since I've done a todo post for Wyam, so I figured it was about time. In this post I'll show you how to make a nice one-page GitHub profile site. We'll use the GitHub module to fetch data from GitHub about your account and then render it using a Razor view. The whole thing is about 50 lines of code between the Wyam config file and the minimum Razor template (not counting a pretty style, which we'll add at the end).

Read more...

Running A Design-Time Build With MSBuild APIs

Getting source files, references, and build properties without invoking the compiler.

The MSBuild APIs are now on NuGet and target netstandard which is awesome, but unfortunately they won't work out of the box with certain platform and project type combinations. The reasons are complex, but basically come down to MSBuild not being a self contained project system. In order for the MSBuild APIs to work with certain project types like SDK-style, MSBuild needs to be told where to find the extra stuff that it needs (like the SDK targets) before it can process the project file. Additionally, if all you care about is metadata like the resolved source files, references, and project properties then you don't actually have to run the compiler. Once you can open the project in MSBuild you can tell it to perform a design-time build which gives you this information without the performance hit of actually compiling the project. Doing so can be valuable for a number of different use cases including code generation, documentation engines, and build orchestration. This post explains some tricks for getting MSBuild to work for any project and then using it to get project metadata without triggering a compilation.

Read more...