A collection of 7 posts


Custom model validation in ASPNET Core

I just wanted to post how to do custom model validation. It took me a few hours and it wasn't posted anywhere yet. So, I wanted to do my own model validation so I can call ModelState.IsValid and get whether the posted model was valid or not. I needed some custom code. In my case it was to make sure that only 1 of 2 boolean properties were set to true. After digging through the sources I found an easy way. Implement the System.ComponentModel.DataAnnotations.IValidatableObject interface. The def


ASP.NET vNext Custom Authentication

Welcome all, here's my delima. I need to be able to implement my own custom Authentication middleware in vNext. I needed to do this because of a requirement where I cannot use cookies. Reason being is that my site will be iFramed into another application. I know, its not a good solution, but it is what it is. There was little to no documentation on how to implement your own authentication middleware so I set out on a journey. It's relatively easy to set it up and get it going. Now, this is not f


ASP 5 vNext WebAPI Abstract/Inherited Classes

Good evening everyone, I've been fighting vNext, Web API and abstract classes. I just want to be able to pass an array into my API of a bunch of different types that all inherit a base class. Turns out it's a configuration option as vNext uses Newtonsoft.JSON to do the serialize/deserialize it was just a matter of finding it. Here's an example what I want passed into my API. public abstract class FilterBase { } public class Filter1 : FilterBase { public string FilterString { get; set; } }


Enhanced security in web sites (headers)

Hey all, so, just got back from a pretty good "Secure Coding" conference from SANS. Learned a lot of stuff. Including some simple countermeasure you can implement on you site. Not all browsers support them, but, with them, it helps prevent Cross Site Scripting. I have create a little .net library that will help with implementing them, along with a sample web app. I encourage you all to go look at it at: It's really easy to use. Hopefully you a


Converting non MVC3 projects to MVC3 projects

Well, I needed to do this because the project that the codgen tool in Orchard creates is not an MVC3 project. Call me picky, but I like the Add Control, Goto View, Create View, and all the other cool little things that come with an MVC project in Visual Studio. So, I set out to figure out how to do it. It's pretty easy, in the .csproj file, there is a project type GUIDs element. Starts out as something like this: <ProjectTypeGuids>{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids> just