This project is read-only.

ASP.NET Identity for Web Forms

Feb 16, 2014 at 10:45 AM
I love Web Forms but am eternally disappointed when I compare the code of any Web Forms sample with its MVC equivalent. This applies to the ASP.NET Idendity code samples that ship with VS 2013. The Web Forms sample has all the code crammed into the codebehind without a thought given to maintenance or unit testing.

Instead of crying into my soup I decided to rewrite the ASP.NET Identity Web Forms sample. In my version the codebehind is empty and the code structure resembles the ASP.NET Identity MVC sample. I've also written an ASP.NET Idendity Web Forms SPA sample. It's progressively enhanced to ensure it's SEO-friendly and works across all devices.

Both these samples can be found at by downloading the link called Navigation Identity for VS

Could we work together to promote these ASP.NET Identity Web Forms samples over the one built into VS 2013?

Mar 22, 2014 at 12:13 PM
I believe samples are meant for showing API usage, not to show how to built maintainable code.
Mar 22, 2014 at 7:26 PM
These Identity samples are included in the ASP.NET templates shipped with VS 2013, so I think they've got a lot of more responsibility on their shoulders than your common or garden code sample. Whenever you create a new Web project in VS 2013 the relevant Idenity 'sample' is included by default.

The code doesn't come with any warning stating that it's not production strength, or that it's for api demonstration only. The implication is that it's a fully realised implentation. Any code shipped with VS 2013 is endowed with the Microsoft seal of approval. Developers will study this code, assuming it is following best practice, and will use it as a template on which to base the rest of their code.

Have you had a look at my Web Forms sample and compared it with the one shipped with VS 2013?
Mar 25, 2014 at 10:59 AM
Firstly can I say what an educating experience it has been looking at your source code. I have been using Web Forms for many years I I hadn't even realised it was possible to create such clean and well structured pages and code. It begs the question as to why one doesn't see more code like this on the Internet and specifically, as you suggest above, why the samples provided by Microsoft do not follow these examples - or, at the very least, provide them as an alternative.

Your comment about Microsoft's responsibility is absolutely correct. The reality is that as a 'jobbing developer' I tend to look to Microsoft as the primary source of information and direction. I am ashamed to say that if Microsoft provide sample code and templating, then I tend to accept this as 'the correct approach'. An hour with your code this morning has proven this approach to be less than optimal.

I hope you are successful in convincing Microsoft to follow your design patterns or, at the very least, help promote them as an alternative approach.

Finally, the only reason I found your posts was that I was looking for examples of how to implement the latest Identity 2.0. Do you have any plans to update your examples to the later version?

Thanks again.
Mar 25, 2014 at 7:19 PM
I really appreciate you taking the time to write such a considered reply. But you're being too harsh on yourself because it's natural to assume that Microsoft authored templates shipped with Visual Studio exhibit the very best of coding principles. Which is why it's frustrating when the template code reinforces the false notion that if you want to write good code you must use MVC.

Thanks for your support and I hope it nudges the project owners towards having a look at my Identity samples.

I've no plan in the short term to update the samples for Identity 2.0 because I've got some important enhancements to make to my Navigation framework. However, might you be interested in updating the samples? If you are interested, let me know and we can discuss further.
Mar 25, 2014 at 10:10 PM
Hello Graham,

Interested yes, but equally uncertain... I'm not sure I currently have enough time or understanding of either the new ASP.NET Identity classes or your elegant approach to coding Web Forms to make a good attempt at this, but I'll certainly have a 'play around' with the code and come back to you in a day or two if that's OK?
Mar 25, 2014 at 11:05 PM
No problem at all. Look forward to hearing from you. If you want any help, big or small, drop me message