How can I cleanly share a Custom Validator (ValidationAttribute) for a data model, a ViewModel, and a DTO in ASP.NET

I’m doing a ASP.NET MVC course. I’m building a REST Web API using ASP.NET WebAPI 2. The application also contains standard MVC 5 views. I’m using DTOs (Data Transfer Objects) to decouple the API from the data model. I’ve made a custom ValidationAttribute that I have applied to a property in my data model, and I’d like to use the same Validation attribute for a property on my DTO as well as a property ViewModel used in an MVC view.

Asp.Net 5 Authentication cookie is reset after every rebuild – How can I truly persist it?

I have a problem with an Asp.Net 5 application I’m currently developing. Essentially it’s an anonymous page with user-attached data, so I’m very much dependant on having a persistent and reliable cookie to identify a calling user. Therefore, I have also checked how I need to configure cookies, and put them on a very long expiration timespan, and made them persistent.