Aspnet dating date or hate dating
NET Web Pages (a platform using only Razor pages) have merged into a unified MVC 6.
NET MVC views format your properties of type datetime correctly? And I’ve been shot in the leg by weird hacks made by both me (just 6 months earlier) or someone else. NET Date/Date Time formatting is an endless bag of fun in general. Note: This guide does not describe localization on the whole.
I’ll readily admit it – this is kind of a tricky one.
I’m not sure if I would recommend this almost ever.
There’s multiple ways you can try and annotate the format directly on your model.
As a first thing task detects current build number. Then regular expression (Version Filter) is applied to build number and as a result date based version number is extracted.
As their code is covered with automated tests and other diagnostics I’m using Azure Dev Ops as build server and this is where I made automated date based versioning work.
Before religious wars about versioning I mention that this kind of versioning doesn’t expose absolute truth or best practices.
However, if you need to support multiple locales (or multiple date formats) for this particular property, this approach is not optimal. Weirdly enough, the Text Box For is an odd bird and doesn’t adhere to the same format specified for Date Time that other methods seem to work fine with. Text Box For() -calls the Data Annotations won’t do the trick.
This method doesn’t care about the format specified via data annotations at all.